USE [master]
GO
/****** Object:  Database [wixeurope_new]    Script Date: 2015-11-11 14:18:40 ******/
CREATE DATABASE [wixeurope_new]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'b2net11', FILENAME = N'd:\db\data\08001726_141007_new.mdf' , SIZE = 865984KB , MAXSIZE = 921600KB , FILEGROWTH = 10%)
 LOG ON 
( NAME = N'b2net11_log', FILENAME = N'd:\db\data\08001726_141007_log_new.ldf' , SIZE = 1008000KB , MAXSIZE = 2764800KB , FILEGROWTH = 10%)
GO
ALTER DATABASE [wixeurope_new] SET COMPATIBILITY_LEVEL = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [wixeurope_new].[dbo].[sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [wixeurope_new] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [wixeurope_new] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [wixeurope_new] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [wixeurope_new] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [wixeurope_new] SET ARITHABORT OFF 
GO
ALTER DATABASE [wixeurope_new] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [wixeurope_new] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [wixeurope_new] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [wixeurope_new] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [wixeurope_new] SET CURSOR_CLOSE_ON_COMMIT ON 
GO
ALTER DATABASE [wixeurope_new] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [wixeurope_new] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [wixeurope_new] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [wixeurope_new] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [wixeurope_new] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [wixeurope_new] SET  DISABLE_BROKER 
GO
ALTER DATABASE [wixeurope_new] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [wixeurope_new] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [wixeurope_new] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [wixeurope_new] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [wixeurope_new] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [wixeurope_new] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [wixeurope_new] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [wixeurope_new] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [wixeurope_new] SET  MULTI_USER 
GO
ALTER DATABASE [wixeurope_new] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [wixeurope_new] SET DB_CHAINING OFF 
GO
ALTER DATABASE [wixeurope_new] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [wixeurope_new] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
USE [wixeurope_new]
GO
/****** Object:  User [wix]    Script Date: 2015-11-11 14:18:40 ******/
CREATE USER [wix] FOR LOGIN [wix] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  User [Kuba]    Script Date: 2015-11-11 14:18:40 ******/
CREATE USER [Kuba] FOR LOGIN [Kuba] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  User [08001726_141007]    Script Date: 2015-11-11 14:18:40 ******/
CREATE USER [08001726_141007] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_owner] ADD MEMBER [wix]
GO
ALTER ROLE [db_owner] ADD MEMBER [08001726_141007]
GO
ALTER ROLE [db_securityadmin] ADD MEMBER [08001726_141007]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [08001726_141007]
GO
ALTER ROLE [db_datareader] ADD MEMBER [08001726_141007]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [08001726_141007]
GO
/****** Object:  StoredProcedure [dbo].[filtron_filters_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_filters_import]
AS
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @filter_number NVARCHAR(100);
DECLARE @filter_wix_number NVARCHAR(100);
DECLARE @filter_wix_number_hd NVARCHAR(100);
DECLARE @filter_service NVARCHAR(10);
DECLARE @filter_shape NVARCHAR(80);
DECLARE @filter_principle_applications NVARCHAR(500);	
DECLARE @filter_anti_siphon_valve BIT;
DECLARE @filter_by_pass_valve BIT;
DECLARE @filter_anti_drain_valve BIT;
DECLARE @filter_dim_a DECIMAL(18,4);
DECLARE @filter_dim_b DECIMAL(18,4);
DECLARE @filter_dim_c DECIMAL(18,4);
DECLARE @filter_dim_d DECIMAL(18,4);
DECLARE @filter_dim_e DECIMAL(18,4);
DECLARE @filter_dim_f DECIMAL(18,4);
DECLARE @filter_dim_g DECIMAL(18,4);
DECLARE @filter_dim_h DECIMAL(18,4);
DECLARE @filter_dim_a_text NVARCHAR(100);
DECLARE @filter_dim_b_text NVARCHAR(100);
DECLARE @filter_dim_c_text NVARCHAR(100);
DECLARE @filter_dim_d_text NVARCHAR(100);
DECLARE @filter_dim_e_text NVARCHAR(100);
DECLARE @filter_dim_f_text NVARCHAR(100);
DECLARE @filter_dim_g_text NVARCHAR(100);
DECLARE @filter_dim_h_text NVARCHAR(100);
DECLARE @filter_illustration NVARCHAR(100);	
DECLARE @filter_service_id INT;
DECLARE @filter_shape_id INT;
DECLARE @filter_media_id INT;
DECLARE @filter_id INT;
BEGIN
  BEGIN TRY
		BEGIN TRANSACTION  
		DECLARE filters_import_cursor CURSOR FOR
			SELECT DISTINCT Nazwa, Rodzaj, typ, zastosowania, dbo.filtron_convert_char_to_bool(By_pass_Valve), 
				dbo.filtron_convert_char_to_bool(Anti_drain_Valve), dbo.filtron_convert_char_to_bool(Anti_syphon_Valve),
				CONVERT(DECIMAL(18,4), REPLACE(dim2A, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2B, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2C, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2D, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2E, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2F, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2G, ',', '.')),
				CONVERT(DECIMAL(18,4), REPLACE(dim2H, ',', '.')),
				PDF, wix_numer, wix_numer_hd, 
				od, id, dimC, dimD, dimE, dimF, dimG, hgt
      FROM import_filtron_filtry_bac
		OPEN filters_import_cursor
		FETCH NEXT FROM filters_import_cursor INTO @filter_number, @filter_service, @filter_shape, 
				@filter_principle_applications, @filter_by_pass_valve, @filter_anti_drain_valve, 
				@filter_anti_siphon_valve, @filter_dim_a, @filter_dim_b, @filter_dim_c,
				@filter_dim_d, @filter_dim_e, @filter_dim_f, @filter_dim_g, @filter_dim_h,
				@filter_illustration, @filter_wix_number, @filter_wix_number_hd, @filter_dim_a_text, 
				@filter_dim_b_text, @filter_dim_c_text, @filter_dim_d_text, @filter_dim_e_text, 
				@filter_dim_f_text, @filter_dim_g_text, @filter_dim_h_text
		WHILE @@FETCH_STATUS = 0
		BEGIN
			EXEC @filter_service_id = filtron_get_filter_type_id @filter_service
			IF (@filter_service_id = -1)
				SET @filter_service_id = NULL			
			EXEC @filter_shape_id = filtron_get_filter_shape_id @filter_shape
			IF (@filter_shape_id = -1)
				SET @filter_shape_id = NULL
			EXEC @filter_media_id = filtron_get_filter_media_id @filter_shape
			IF (@filter_media_id = -1)
				SET @filter_media_id = NULL
			SET @filter_id = NULL 			
			SELECT @filter_id = filter_id 
				FROM filtron_filters
				WHERE filter_number = @filter_number
			IF (@filter_id IS NOT NULL)
				UPDATE filtron_filters SET
					filter_number = @filter_number, filter_number_trim = REPLACE(LTRIM(RTRIM(@filter_number)), ' ', ''), 
					filter_type_id = @filter_service_id, filter_media_id = @filter_media_id, filter_style_id = NULL, 
					filter_shape_id = @filter_shape_id, filter_by_pass_valve = @filter_by_pass_valve,
					filter_anti_drain_valve = @filter_anti_drain_valve, filter_anti_siphon_valve = @filter_anti_siphon_valve, 
					filter_principle_applications = @filter_principle_applications, 
					filter_dim_a = @filter_dim_a, filter_dim_b = @filter_dim_b, filter_dim_c = @filter_dim_c, 
					filter_dim_d = @filter_dim_d, filter_dim_e = @filter_dim_e, filter_dim_f = @filter_dim_f, 
					filter_dim_g = @filter_dim_g, filter_dim_h = @filter_dim_h, filter_wix_number = @filter_wix_number, 
					filter_wix_number_hd = @filter_wix_number_hd, filter_dim_a_text = @filter_dim_a_text, 
					filter_dim_b_text = @filter_dim_b_text, filter_dim_c_text = @filter_dim_c_text, 
					filter_dim_d_text = @filter_dim_d_text, filter_dim_e_text = @filter_dim_e_text, 
					filter_dim_f_text = @filter_dim_f_text, filter_dim_g_text = @filter_dim_g_text, 
					filter_dim_h_text = @filter_dim_h_text
				WHERE filter_id = @filter_id				
			ELSE
				INSERT INTO filtron_filters (filter_number, filter_number_trim, filter_type_id,  
						filter_media_id, filter_style_id, filter_shape_id, filter_by_pass_valve,
						filter_anti_drain_valve, filter_anti_siphon_valve, filter_principle_applications, 
						filter_dim_a, filter_dim_b, filter_dim_c, filter_dim_d, filter_dim_e, filter_dim_f, 
						filter_dim_g, filter_dim_h, filter_wix_number, filter_wix_number_hd, 
						filter_dim_a_text, filter_dim_b_text, filter_dim_c_text, filter_dim_d_text, 
						filter_dim_e_text, filter_dim_f_text, filter_dim_g_text, filter_dim_h_text)
				VALUES (@filter_number, LTRIM(RTRIM(@filter_number)), @filter_service_id, 
						@filter_media_id, NULL, @filter_shape_id, @filter_by_pass_valve, @filter_anti_drain_valve, 
						@filter_anti_siphon_valve, @filter_principle_applications, @filter_dim_a, 
						@filter_dim_b, @filter_dim_c, @filter_dim_d, @filter_dim_e, @filter_dim_f, 
						@filter_dim_g, @filter_dim_h, @filter_wix_number, @filter_wix_number_hd, 
						@filter_dim_a_text, @filter_dim_b_text, @filter_dim_c_text, @filter_dim_d_text, 
						@filter_dim_e_text, @filter_dim_f_text, @filter_dim_g_text, @filter_dim_h_text 
			)
		FETCH NEXT FROM filters_import_cursor INTO @filter_number, @filter_service, @filter_shape, 
				@filter_principle_applications, @filter_by_pass_valve, @filter_anti_drain_valve, 
				@filter_anti_siphon_valve, @filter_dim_a, @filter_dim_b, @filter_dim_c,
				@filter_dim_d, @filter_dim_e, @filter_dim_f, @filter_dim_g, @filter_dim_h,
				@filter_illustration, @filter_wix_number, @filter_wix_number_hd, @filter_dim_a_text, 
				@filter_dim_b_text, @filter_dim_c_text, @filter_dim_d_text, @filter_dim_e_text, 
				@filter_dim_f_text, @filter_dim_g_text, @filter_dim_h_text
		END
		CLOSE filters_import_cursor
		DEALLOCATE filters_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE filters_import_cursor
		DEALLOCATE filters_import_cursor
		IF @@TRANCOUNT > 0
			ROLLBACK TRANSACTION
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
	IF @@TRANCOUNT > 0
		COMMIT TRANSACTION
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_engine_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_engine_id]
(	
	@vehicle_id INT,
	@model_id INT,
	@engine_name NVARCHAR(100),
	@engine_code NVARCHAR(100),
	@engine_cubic_capacity NVARCHAR(100),
	@engine_horse_power NVARCHAR(255),
	@engine_description NVARCHAR(500),
	@engine_years NVARCHAR(500) 
)
AS
DECLARE @engine_id INT;
DECLARE @engine_year_from INT;
DECLARE @engine_year_to INT;
DECLARE @engine_year_from_table INT;
DECLARE @engine_year_to_table INT;
DECLARE @engine_model_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@vehicle_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_engine_id error, vehicle_id NULL',
    	  10,
      	10
    	);
  	IF (@model_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_engine_id error, model_id NULL',
    	  10,
      	10
    	);
  	IF ((@engine_name IS NULL) OR (@engine_name = ''))
 			RETURN -1
  	IF ((@engine_code IS NULL) OR (@engine_code = ''))			  		
			SELECT @engine_id = engine_id, @engine_year_from_table = engine_year_from, 
				@engine_year_to_table = engine_year_to
				FROM filtron_engines
				WHERE (UPPER(engine_name) = UPPER(@engine_name)) AND (vehicle_id = @vehicle_id)
				  AND (engine_horse_power = @engine_horse_power) AND (engine_cubic_capacity = @engine_cubic_capacity)
		ELSE				
			SELECT @engine_id = engine_id, @engine_year_from_table = engine_year_from, 
				@engine_year_to_table = engine_year_to
				FROM filtron_engines
				WHERE (UPPER(engine_name) = UPPER(@engine_name)) 
					AND (vehicle_id = @vehicle_id)
					AND (UPPER(engine_code) = UPPER(@engine_code))
					AND (engine_horse_power = @engine_horse_power) AND (engine_cubic_capacity = @engine_cubic_capacity)
		IF (@engine_id IS NULL)
		BEGIN
			INSERT INTO filtron_engines (engine_name, engine_code, engine_description, engine_cubic_capacity, engine_horse_power, vehicle_id)
			VALUES (@engine_name, @engine_code, @engine_description, @engine_cubic_capacity, @engine_horse_power, @vehicle_id)
			SET @engine_id = IDENT_CURRENT ('filtron_engines')
			IF (@engine_id IS NULL)
				RETURN -1
		END
		IF ((@engine_years IS NOT NULL) AND (@engine_years <> ''))
		BEGIN
			SET @engine_year_from = dbo.filtron_get_engine_year_from(@engine_years)
			IF (@engine_year_from > -1) 
			BEGIN
				IF ((@engine_year_from_table IS NULL) OR (@engine_year_from_table > @engine_year_from))
					UPDATE filtron_engines SET engine_year_from = @engine_year_from
					WHERE engine_id = @engine_id
			END 
			SET @engine_year_to = dbo.filtron_get_engine_year_to(@engine_years)
			IF (@engine_year_to > -1) 
			BEGIN
				IF ((@engine_year_to_table IS NULL) OR (@engine_year_to_table < @engine_year_to))
					UPDATE filtron_engines SET engine_year_to = @engine_year_to
					WHERE engine_id = @engine_id
			END 
		END		
		SELECT @engine_model_id = engine_model_id 
			FROM filtron_engine_models
			WHERE (engine_id = @engine_id) AND (model_id = @model_id)
		IF (@engine_model_id IS NULL)
			INSERT INTO filtron_engine_models (engine_id, model_id) VALUES (@engine_id, @model_id) 
		RETURN @engine_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_filter_engine_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_filter_engine_id]
(	
	@filter_id INT,
	@engine_id INT,
	@model_id INT,
	@filter_additional_info NVARCHAR(500),
	@filter_other_info NVARCHAR(255)
)
AS
DECLARE @filter_engine_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@filter_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_filter_engine_id error, filter_id NULL',
    	  10,
      	10
    	);
  	IF (@engine_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_filter_engine_id error, engine_id NULL',
    	  10,
      	10
    	);
  	IF (@model_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_filter_engine_id error, model_id NULL',
    	  10,
      	10
    	);
		SELECT @filter_engine_id = filter_engine_id
			FROM filtron_filter_engines
			WHERE (filter_id = @filter_id) 
						AND (engine_id = @engine_id)
						AND (model_id = @model_id);
		IF (@filter_engine_id IS NULL)
		BEGIN
			INSERT INTO filtron_filter_engines (filter_id, engine_id, model_id, filter_additional_info, filter_other_info)
			VALUES (@filter_id, @engine_id, @model_id, @filter_additional_info, @filter_other_info)
			SET @filter_engine_id = IDENT_CURRENT ('filtron_filter_engines')
		END
		ELSE
			UPDATE filtron_filter_engines SET filter_additional_info = @filter_additional_info, 
				filter_other_info = @filter_other_info
			WHERE filter_engine_id = @filter_engine_id
		IF (@filter_engine_id > 0)
		BEGIN
			IF (((@filter_additional_info IS NOT NULL) AND (@filter_additional_info <> '')) OR
					((@filter_other_info IS NOT NULL) AND (@filter_other_info <> '')))
			BEGIN
				INSERT INTO filtron_filter_engine_comments (filter_engine_id, filter_info_years, filter_info_description)
					VALUES (@filter_engine_id, @filter_other_info, @filter_additional_info)
			END				
		END
		RETURN @filter_engine_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_filter_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_filter_id]
(	
	@in_filter_id INT,
	@in_filter_style_name NVARCHAR(100) 
)
AS
DECLARE @filter_id INT;
DECLARE @filter_style_id INT;
DECLARE @filter_number NVARCHAR(100);
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@in_filter_id IS NULL)
  		RETURN -1
  	SELECT @filter_number = nazwa
  		FROM import_filtron_filtry_bac
  		WHERE idfiltr = @in_filter_id
  	IF ((@filter_number IS NULL) OR (@filter_number = ''))
  		RETURN -1
		SELECT @filter_id = filter_id
			FROM filtron_filters
			WHERE filter_number = @filter_number
		IF (@filter_id IS NOT NULL)
		BEGIN
			EXEC @filter_style_id = filtron_get_filter_style_id @in_filter_style_name
			IF (@filter_style_id > 0)
				UPDATE filtron_filters 
					SET filter_style_id = @filter_style_id
					WHERE filter_id = @filter_id
					AND filter_style_id IS NULL
			RETURN @filter_id 
		END
		RETURN -1 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_filter_media_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_filter_media_id]
(	
	@filter_media_abbr NVARCHAR(10)
)
AS
DECLARE @filter_media_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@filter_media_abbr IS NULL) OR (@filter_media_abbr = '')
  		RETURN -1
		SELECT @filter_media_id = media_id
			FROM filtron_filter_medias
			WHERE UPPER(media_abbr) = UPPER(@filter_media_abbr);
		IF (@filter_media_id IS NULL)
		BEGIN
			INSERT INTO filtron_filter_medias (media_name,media_abbr)
			VALUES (@filter_media_abbr, @filter_media_abbr)
			RETURN IDENT_CURRENT ('filtron_filter_medias')
		END
		RETURN @filter_media_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_filter_shape_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_filter_shape_id]
(	
	@filter_shape_abbr NVARCHAR(10)
)
AS
DECLARE @filter_shape_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@filter_shape_abbr IS NULL) OR (@filter_shape_abbr = '')
  		RETURN -1
		SELECT @filter_shape_id = shape_id
			FROM filtron_filter_shapes
			WHERE UPPER(shape_abbr) = UPPER(@filter_shape_abbr);
		IF (@filter_shape_id IS NULL)
		BEGIN
			INSERT INTO filtron_filter_shapes (shape_name,shape_abbr)
			VALUES (@filter_shape_abbr, @filter_shape_abbr)
			RETURN IDENT_CURRENT ('filtron_filter_shapes')
		END
		RETURN @filter_shape_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_filter_style_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_filter_style_id]
(	
	@filter_style_abbr NVARCHAR(10)
)
AS
DECLARE @filter_style_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY                                                          
		IF ((@filter_style_abbr IS NULL) OR (@filter_style_abbr = ''))
			RETURN -1
		SELECT @filter_style_id = style_id
			FROM filtron_filter_styles
			WHERE UPPER(style_abbr) = UPPER(@filter_style_abbr);
		IF (@filter_style_id IS NULL)
		BEGIN
			INSERT INTO filtron_filter_styles (style_name, style_abbr)
			VALUES (@filter_style_abbr, @filter_style_abbr)
			RETURN IDENT_CURRENT ('filtron_filter_styles')
		END
		RETURN @filter_style_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_filter_type_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_filter_type_id]
(	
	@filter_type_abbr NVARCHAR(10)
)
AS
DECLARE @filter_type_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY                                                          
		IF ((@filter_type_abbr IS NULL) OR (@filter_type_abbr = ''))
			SET @filter_type_abbr = 'NN';
		SELECT @filter_type_id = type_id
			FROM filtron_filter_types
			WHERE UPPER(type_abbr) = UPPER(@filter_type_abbr);
		IF (@filter_type_id IS NULL)
		BEGIN
			INSERT INTO filtron_filter_types (type_name, type_abbr)
			VALUES (@filter_type_abbr, @filter_type_abbr)
			RETURN IDENT_CURRENT ('filtron_filter_types')
		END
		RETURN @filter_type_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_make_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_make_id]
(	
	@vehicle_id INT,
	@make_name NVARCHAR(100)
)
AS
DECLARE @make_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@vehicle_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_make_id error, vehicle_id NULL',
    	  10,
      	10
    	);
  	IF ((@make_name IS NULL) OR (@make_name = ''))
 			RETURN -1 		
		SELECT @make_id = make_id
			FROM filtron_makes
			WHERE (UPPER(make_name) = UPPER(@make_name)) AND (vehicle_id = @vehicle_id);
		IF (@make_id IS NULL)
		BEGIN
			INSERT INTO filtron_makes (make_name, vehicle_id)
			VALUES (@make_name, @vehicle_id)
			RETURN IDENT_CURRENT ('filtron_makes')
		END
		RETURN @make_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_manufacturer_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_manufacturer_id]
(	
	@in_manufacturer_id INT 
)
AS
DECLARE @manufacturer_id INT;
DECLARE @manufacturer_name NVARCHAR(500);
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@in_manufacturer_id IS NULL)
  		RETURN -1
  	SELECT @manufacturer_name = firma
  		FROM import_filtron_firmy_bac
  		WHERE IDFirma = @in_manufacturer_id
  	IF ((@manufacturer_name IS NULL) OR (@manufacturer_name = ''))
  		RETURN -1
		SELECT @manufacturer_id = manufacturer_id
			FROM filtron_interchange_manufacturers
			WHERE UPPER(manufacturer_name) = UPPER(@manufacturer_name);
		IF (@manufacturer_id IS NULL)
		BEGIN
			INSERT INTO filtron_interchange_manufacturers (manufacturer_name, manufacturer_description)
			VALUES (@manufacturer_name, @manufacturer_name)
			RETURN IDENT_CURRENT ('filtron_interchange_manufacturers')
		END
		RETURN @manufacturer_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_model_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_model_id]
(	
	@make_id INT,
	@model_name NVARCHAR(100)
)
AS
DECLARE @model_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@make_id IS NULL)
	    RAISERROR(
  	    'Procedure filtron_get_model_id error, make_id NULL',
    	  10,
      	10
    	);
  	IF ((@model_name IS NULL) OR (@model_name = ''))
 			RETURN -1 		
		SELECT @model_id = model_id
			FROM filtron_models
			WHERE (UPPER(model_name) = UPPER(@model_name)) AND (make_id = @make_id);
		IF (@model_id IS NULL)
		BEGIN
			INSERT INTO filtron_models (model_name, make_id)
			VALUES (@model_name, @make_id)
			RETURN IDENT_CURRENT ('filtron_models')
		END
		RETURN @model_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_get_shape_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_shape_id]
(	
	@in_filter_id INT
)
AS
DECLARE @filter_media_id INT;
DECLARE @filter_type_id INT;
DECLARE @filter_shape_id INT;
DECLARE @dict_id INT;
DECLARE @dim_no INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@in_filter_id IS NULL)
  		RETURN -1
  	SELECT @filter_media_id = filter_media_id, @filter_type_id = filter_type_id  	   
  		FROM filtron_filters
  		WHERE filter_id = @in_filter_id
  	IF (@filter_media_id IS NULL)
  		RETURN -1
  	IF (@filter_type_id IS NULL)
  		RETURN -1
	SELECT @dim_no = CAST(media_abbr AS INT)
		FROM filtron_filter_medias
		WHERE media_id = @filter_media_id
  	SELECT @dict_id = dictid 
      FROM import_filtron_ext_dim_bac
      WHERE dim_no = @dim_no
  	IF (@dict_id IS NULL)
  		RETURN -1
  	SELECT DISTINCT @filter_shape_id = shape_id  	   
  		FROM filtron_filter_type_shapes
  		WHERE dict_id = @dict_id 
  	IF (@filter_shape_id IS NULL)
  		RETURN -1
  	RETURN @filter_shape_id
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END
GO
/****** Object:  StoredProcedure [dbo].[filtron_get_single_filter_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_get_single_filter_id]
(	
	@in_filter_number NVARCHAR(100) 
)
AS
DECLARE @filter_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@in_filter_number IS NULL)
  		RETURN -1
  	SELECT @filter_id = filter_id
  		FROM filtron_filters
  		WHERE filter_number = @in_filter_number
  	IF (@filter_id IS NULL)
  		RETURN -1
  	RETURN @filter_id
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_import]
(
	@vehicle_id INT,
	@filtron_vehicle_id INT,
	@start_row INT,
	@end_row INT	
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @years NVARCHAR(100);
DECLARE @prevYears NVARCHAR(100);
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @prev_engine_name NVARCHAR(100);
DECLARE @engine_type_name NVARCHAR(100);
DECLARE @prev_engine_type_name NVARCHAR(100);
DECLARE @engine_description NVARCHAR(300);
DECLARE @engine_cubic_capacity NVARCHAR(100);
DECLARE @engine_horse_power NVARCHAR(255);
DECLARE @prev_engine_cubic_capacity NVARCHAR(100);
DECLARE @prev_engine_horse_power NVARCHAR(255);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_olej_id INT;
DECLARE @filter_pow_id INT;
DECLARE @filter_paliwo_id INT;
DECLARE @filter_inne_id INT;
DECLARE @filter_inne_type NVARCHAR(100);
DECLARE @filter_engine_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
	SET @prev_engine_name = '';
	SET @prev_engine_type_name = '';
	SET @prev_engine_cubic_capacity = '';
	SET @prev_engine_horse_power = '';
	SET @prevYears = '';
  BEGIN TRY
		DECLARE import_cursor CURSOR FOR
			SELECT marka, model, silnik, opcja, poj_silnika, typ_silnika, moc, 
				lata, idfpow, idfolej, idfpaliw, idfinne, finnetyp 
      FROM (
				SELECT import_filtron_marka_bac.marka, import_filtron_model_bac.model, import_filtron_katalog_bac.silnik,
					import_filtron_katalog_bac.opcja, import_filtron_katalog_bac.poj_silnika, 
					import_filtron_katalog_bac.typ_silnika, import_filtron_katalog_bac.moc, 
					import_filtron_katalog_bac.lata, import_filtron_katalog_bac.idfpow, 
					import_filtron_katalog_bac.idfolej, import_filtron_katalog_bac.idfpaliw, 
					import_filtron_katalog_bac.idfinne, import_filtron_katalog_bac.finnetyp,
					ROW_NUMBER() OVER (ORDER BY import_filtron_katalog_bac.identyfikator) AS row_num 
      	FROM import_filtron_katalog_bac
      	LEFT JOIN import_filtron_marka_bac ON (import_filtron_marka_bac.idmarka = import_filtron_katalog_bac.idmarka)
      	LEFT JOIN import_filtron_model_bac ON (import_filtron_model_bac.idmodel = import_filtron_katalog_bac.idmodel)
      	WHERE idtyp = @filtron_vehicle_id               		
			) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row 
		OPEN import_cursor
		FETCH NEXT FROM import_cursor INTO @make_name, @model_name, @engine_name, 
			@engine_description, @engine_cubic_capacity, @engine_type_name, @engine_horse_power, 
			@years, @filter_pow_id, @filter_olej_id, @filter_paliwo_id, @filter_inne_id, 
			@filter_inne_type
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_olej_id IS NOT NULL) OR (@filter_pow_id IS NOT NULL) OR (@filter_paliwo_id IS NOT NULL) OR (@filter_inne_id IS NOT NULL))
			BEGIN
            IF (((@years IS NOT NULL) AND (@years <> '')) OR (@prev_engine_name <> @engine_name)
                  OR (@prev_engine_type_name <> @engine_type_name)
                  OR (@prev_engine_cubic_capacity <> @engine_cubic_capacity)
                  OR (@prev_engine_horse_power <> @engine_horse_power)) 
               SET @prevYears = @years			
				EXEC @make_id = filtron_get_make_id @vehicle_id, @make_name
				IF (@make_id > 0)
					BEGIN
					EXEC @model_id = filtron_get_model_id @make_id, @model_name
				  IF (@model_id > 0)
				  BEGIN
				  	EXEC @engine_id = filtron_get_engine_id @vehicle_id, @model_id, @engine_name, @engine_type_name, @engine_cubic_capacity, @engine_horse_power, @engine_description, @years
					  IF (@engine_id > 0)
					  BEGIN
 				  		EXEC @filter_id = filtron_get_filter_id @filter_olej_id, 'OIL'
						  IF (@filter_id > 0)
						  BEGIN
						   IF ((@years IS NOT NULL) AND (@years <> ''))
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @years
						  	ELSE
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @prevYears
							IF (@filter_engine_id > 0)
							  SET @rows_affected = @rows_affected + 1 	 
						  END
 				  		EXEC @filter_id = filtron_get_filter_id @filter_pow_id, 'AIR'
						  IF (@filter_id > 0)
						  BEGIN
						   IF ((@years IS NOT NULL) AND (@years <> ''))
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @years
   						ELSE
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @prevYears
							IF (@filter_engine_id > 0)
							  SET @rows_affected = @rows_affected + 1 	 
							END
 				  		EXEC @filter_id = filtron_get_filter_id @filter_paliwo_id, 'GAS'
						  IF (@filter_id > 0)
						  BEGIN
						   IF ((@years IS NOT NULL) AND (@years <> ''))
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @years
						  	ELSE
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @prevYears
							IF (@filter_engine_id > 0)
							  SET @rows_affected = @rows_affected + 1 	 
							END
 				  		EXEC @filter_id = filtron_get_filter_id @filter_inne_id, @filter_inne_type
						  IF (@filter_id > 0)
						  BEGIN
						   IF ((@years IS NOT NULL) AND (@years <> ''))
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @years
						  	ELSE
						  	   EXEC @filter_engine_id = filtron_get_filter_engine_id @filter_id, @engine_id, @model_id, @engine_description, @prevYears
							IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
						  END
				  	END
			  	END
      	END
      END
      	SET @prev_engine_name = @engine_name;
	      SET @prev_engine_type_name = @engine_type_name;
	      SET @prev_engine_cubic_capacity = @engine_cubic_capacity;
	      SET @prev_engine_horse_power = @engine_horse_power;
			FETCH NEXT FROM import_cursor INTO @make_name, @model_name, @engine_name, 
				@engine_description, @engine_cubic_capacity, @engine_type_name, @engine_horse_power, 
				@years, @filter_pow_id, @filter_olej_id, @filter_paliwo_id, @filter_inne_id, 
				@filter_inne_type
		END
		CLOSE import_cursor
		DEALLOCATE import_cursor
  END TRY
  BEGIN CATCH
		CLOSE import_cursor
		DEALLOCATE import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END
GO
/****** Object:  StoredProcedure [dbo].[filtron_import_shapes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_import_shapes]
AS
DECLARE @filter_id INT;
DECLARE @filter_shape_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
   BEGIN TRY
      DECLARE import_cursor CURSOR FOR
			SELECT filter_id
         FROM filtron_filters
      OPEN import_cursor
		FETCH NEXT FROM import_cursor INTO @filter_id
		WHILE @@FETCH_STATUS = 0
		BEGIN
         EXEC @filter_shape_id = filtron_get_shape_id @filter_id
         IF (@filter_shape_id > 0)
         BEGIN
            UPDATE filtron_filters SET filter_shape_id = @filter_shape_id
            WHERE filter_id = @filter_id
            SET @rows_affected = @rows_affected + 1
         END
   		FETCH NEXT FROM import_cursor INTO @filter_id
		END
		CLOSE import_cursor
		DEALLOCATE import_cursor      		
   END TRY
   BEGIN CATCH
		CLOSE import_cursor
		DEALLOCATE import_cursor
      SELECT 
         @error_message = ERROR_MESSAGE(),
         @error_severity = ERROR_SEVERITY(),
         @error_state = ERROR_STATE();				
       RAISERROR(
         @error_message,
         @error_severity,
         @error_state
       );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_import_text_dims]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[filtron_import_text_dims]
AS
DECLARE @filter_id INT;
DECLARE @filter_dim_a_text NVARCHAR(50);
DECLARE @filter_dim_b_text NVARCHAR(50);
DECLARE @filter_dim_c_text NVARCHAR(50);
DECLARE @filter_dim_d_text NVARCHAR(50);
DECLARE @filter_dim_e_text NVARCHAR(50);
DECLARE @filter_dim_f_text NVARCHAR(50);
DECLARE @filter_dim_g_text NVARCHAR(50);
DECLARE @filter_dim_h_text NVARCHAR(50);
DECLARE @filter_number NVARCHAR(100);
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
   BEGIN TRY
      DECLARE import_cursor CURSOR FOR
			SELECT od, id, dimc, dimd, dime, dimf, dimg, hgt, nazwa
         FROM import_filtron_filtry_bac
      OPEN import_cursor
		FETCH NEXT FROM import_cursor INTO @filter_dim_a_text, @filter_dim_b_text, @filter_dim_c_text, 
			@filter_dim_d_text, @filter_dim_e_text, @filter_dim_f_text, @filter_dim_g_text, 
			@filter_dim_h_text, @filter_number
		WHILE @@FETCH_STATUS = 0
		BEGIN
         EXEC @filter_id = filtron_get_single_filter_id @filter_number
         IF (@filter_id > 0)
         BEGIN
            UPDATE filtron_filters SET filter_dim_a_text = @filter_dim_a_text, 
               filter_dim_b_text = @filter_dim_b_text, filter_dim_c_text = @filter_dim_c_text, 
               filter_dim_d_text = @filter_dim_d_text, filter_dim_e_text = @filter_dim_e_text, 
               filter_dim_f_text = @filter_dim_f_text, filter_dim_g_text = @filter_dim_g_text, 
               filter_dim_h_text = @filter_dim_h_text
            WHERE filter_id = @filter_id
            SET @rows_affected = @rows_affected + 1
         END
   		FETCH NEXT FROM import_cursor INTO @filter_dim_a_text, @filter_dim_b_text, @filter_dim_c_text, 
	     		@filter_dim_d_text, @filter_dim_e_text, @filter_dim_f_text, @filter_dim_g_text, 
	  	     	@filter_dim_h_text, @filter_number
		END
		CLOSE import_cursor
		DEALLOCATE import_cursor      		
   END TRY
   BEGIN CATCH
		CLOSE import_cursor
		DEALLOCATE import_cursor
      SELECT 
         @error_message = ERROR_MESSAGE(),
         @error_severity = ERROR_SEVERITY(),
         @error_state = ERROR_STATE();				
       RAISERROR(
         @error_message,
         @error_severity,
         @error_state
       );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[filtron_zamienniki_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[filtron_zamienniki_import]
(
	@start_row INT,
	@end_row INT
)
AS
DECLARE @import_filter_id INT;
DECLARE @import_firma_id INT;
DECLARE @filter_id INT;
DECLARE @manufacturer_id INT;
DECLARE @interchange_id INT;
DECLARE @foreign_filter_number NVARCHAR(255);
DECLARE @foreign_filter_number_trim NVARCHAR(255);
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE import_cursor CURSOR FOR
			SELECT DISTINCT IDfiltr, IDfirma, Obcy, Obcy_AN
      FROM (
				SELECT DISTINCT IDfiltr, IDfirma, Obcy, Obcy_AN, 
					ROW_NUMBER() OVER (ORDER BY IDZamienniki) AS row_num
      	FROM import_filtron_zamienniki_bac
      ) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN import_cursor
		FETCH NEXT FROM import_cursor INTO @import_filter_id, @import_firma_id, @foreign_filter_number, 
			@foreign_filter_number_trim
		WHILE @@FETCH_STATUS = 0
		BEGIN
			SET @interchange_id = NULL
			EXEC @filter_id = filtron_get_filter_id @import_filter_id, -1
			IF (@filter_id > 0)
			BEGIN
				EXEC @manufacturer_id = filtron_get_manufacturer_id @import_firma_id
				IF (@manufacturer_id > 0)
				BEGIN					
					SELECT @interchange_id = interchange_id
						FROM filtron_interchanges
						WHERE (filter_id = @filter_id) 
							AND (foreign_filter_trim = @foreign_filter_number_trim)
							AND (manufacturer_id = @manufacturer_id)
					IF (@interchange_id IS NULL)
					BEGIN
						INSERT INTO filtron_interchanges (filter_id, manufacturer_id, foreign_filter_number, foreign_filter_trim)
							VALUES (@filter_id, @manufacturer_id, @foreign_filter_number, @foreign_filter_number_trim)
						SET @rows_affected = @rows_affected + 1
					END
				END
			END
			FETCH NEXT FROM import_cursor INTO @import_filter_id, @import_firma_id, @foreign_filter_number, 
				@foreign_filter_number_trim
		END
		CLOSE import_cursor
		DEALLOCATE import_cursor
  END TRY
  BEGIN CATCH
		CLOSE import_cursor
		DEALLOCATE import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[get_comment_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_comment_id]
(	
	@additional_info NVARCHAR(500),
	@filter_engine_id INT,
	@year INT
)
AS
DECLARE @comment_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
		SELECT @comment_id = filter_engine_comment_id
			FROM wix_filter_engine_comments
			WHERE UPPER(filter_additional_info) = UPPER(@additional_info)
        AND filter_engine_id = @filter_engine_id 
        AND applicable_year = @year
		IF (@comment_id IS NULL)
		BEGIN
		  INSERT INTO wix_filter_engine_comments (filter_engine_id, filter_additional_info, applicable_year)
		    VALUES (@filter_engine_id, @additional_info, @year)
		  RETURN IDENT_CURRENT ('wix_filter_engine_comments')
		END
		RETURN @comment_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_engine_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_engine_id]
(	
	@vehicle_id INT,
	@model_id INT,
	@engine_name NVARCHAR(100),
  @engine_year INT
)
AS
DECLARE @engine_id INT;
DECLARE @engine_model_id INT;
DECLARE @engine_description NVARCHAR(255);
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @year_from INT;
DECLARE @year_to INT;
BEGIN
  BEGIN TRY
  	IF (@vehicle_id IS NULL)
	    RAISERROR(
  	    'Procedure get_engine_id error, vehicle_id NULL',
    	  10,
      	10
    	);
  	IF (@model_id IS NULL)
	    RAISERROR(
  	    'Procedure get_engine_id error, model_id NULL',
    	  10,
      	10
    	);
  	SET @engine_description = NULL
  	IF ((@engine_name IS NULL) OR (@engine_name = ''))
 			RETURN -1 		
		SELECT @engine_id = engine_id, @year_from = engine_year_from, @year_to = engine_year_to
			FROM wix_engines
			WHERE (UPPER(engine_name) = UPPER(@engine_name)) AND (vehicle_id = @vehicle_id);
		IF (@engine_id IS NULL)
		BEGIN
			INSERT INTO wix_engines (engine_name, engine_description, vehicle_id, engine_year_from, engine_year_to)
			VALUES (@engine_name, @engine_description, @vehicle_id, @engine_year, @engine_year)
			SET @engine_id = IDENT_CURRENT ('wix_engines')
		END
		ELSE
		BEGIN
			IF (@engine_year IS NOT NULL)
			BEGIN
				IF ((@year_from IS NULL) OR (@year_from > @engine_year))
					UPDATE wix_engines SET engine_year_from = @engine_year
					WHERE engine_id = @engine_id
				IF ((@year_to IS NULL) OR (@year_to < @engine_year))
					UPDATE wix_engines SET engine_year_to = @engine_year
					WHERE engine_id = @engine_id
			END 
			UPDATE wix_engines SET engine_name = @engine_name, engine_description = @engine_description, 
				vehicle_id = @vehicle_id
			WHERE engine_id = @engine_id
		END
		SELECT @engine_model_id = engine_model_id 
			FROM wix_engine_models
			WHERE (engine_id = @engine_id) AND (model_id = @model_id)
		IF (@engine_model_id IS NULL)
			INSERT INTO wix_engine_models (engine_id, model_id) VALUES (@engine_id, @model_id) 
		RETURN @engine_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_engine_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_filter_engine_id]
(	
	@filter_id INT,
	@model_id INT,
	@engine_id INT,
	@year INT, 
	@comment1 NVARCHAR(500),
	@comment2 NVARCHAR(500),	
	@footnote1 INT, 
	@footnote2 INT, 
	@footnote3 INT,
	@engine_exception1 NVARCHAR(100),
  @engine_exception2 NVARCHAR(100),
  @engine_exception3 NVARCHAR(100)	 
)
AS
DECLARE @filter_engine_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @year_from INT;
DECLARE @year_to INT;
DECLARE @footnote1_id INT; 
DECLARE @footnote2_id INT; 
DECLARE @footnote3_id INT; 
DECLARE @filter_engine_footnote_id INT;
DECLARE @filter_engine_comment_id INT;
DECLARE @additional_info NVARCHAR(500);
BEGIN
  BEGIN TRY
  	IF (@filter_id IS NULL)
	    RAISERROR(
  	    'Procedure get_filter_engine_id error, filter_id NULL',
    	  10,
      	10
    	);
  	IF (@model_id IS NULL)
	    RAISERROR(
  	    'Procedure get_filter_engine_id error, model_id NULL',
    	  10,
      	10
    	);
  	IF (@engine_id IS NULL)
	    RAISERROR(
  	    'Procedure get_filter_engine_id error, engine_id NULL',
    	  10,
      	10
    	);
		SET @additional_info = '';    	
		SELECT @filter_engine_id = filter_engine_id, @year_from = year_from, @year_to = year_to
			FROM wix_filter_engines
			WHERE (filter_id = @filter_id) 
						AND (engine_id = @engine_id)
						AND (model_id = @model_id);
		IF (((@comment1 IS NOT NULL) AND (@comment1 <> '')) OR
				((@comment2 IS NOT NULL) AND (@comment2 <> '')))
		BEGIN
			SET @additional_info = COALESCE(@comment1, '');
			IF ((@additional_info <> '') AND (@additional_info IS NOT NULL))
				SET @additional_info = @additional_info + '; ' 
			SET @additional_info = @additional_info + COALESCE(@comment2, '');
		END		
		IF (((@engine_exception1 IS NOT NULL) AND (@engine_exception1 <> '')) OR
				((@engine_exception2 IS NOT NULL) AND (@engine_exception2 <> '')) OR
				((@engine_exception3 IS NOT NULL) AND (@engine_exception3 <> '')))
		BEGIN
			IF ((@engine_exception1 IS NOT NULL) AND (@engine_exception1 <> ''))
				SET @additional_info = @additional_info + '; ' + COALESCE(@engine_exception1, '');
			IF ((@engine_exception2 IS NOT NULL) AND (@engine_exception2 <> ''))
				SET @additional_info = @additional_info + '; ' + COALESCE(@engine_exception2, '');
			IF ((@engine_exception3 IS NOT NULL) AND (@engine_exception3 <> ''))
				SET @additional_info = @additional_info + '; ' + COALESCE(@engine_exception3, '');
		END		
		IF (@filter_engine_id IS NULL)
		BEGIN
			INSERT INTO wix_filter_engines (filter_id, engine_id, model_id, year_from, year_to, filter_additional_info)
			VALUES (@filter_id, @engine_id, @model_id, @year, @year, @additional_info)
			SET @filter_engine_id = IDENT_CURRENT ('wix_filter_engines')
		END
		ELSE
		BEGIN
			IF ((@year_from IS NULL) OR (@year_from > @year))
					UPDATE wix_filter_engines SET year_from = @year
					WHERE filter_engine_id = @filter_engine_id
			IF ((@year_to IS NULL) OR (@year_to < @year))
					UPDATE wix_filter_engines SET year_to = @year
					WHERE filter_engine_id = @filter_engine_id
			UPDATE wix_filter_engines SET filter_additional_info = @additional_info
				WHERE filter_engine_id = @filter_engine_id
		END
		IF (@filter_engine_id > 0)
		BEGIN
			IF (((@footnote1 IS NOT NULL) AND (@footnote1 > 0)) OR
					((@footnote2 IS NOT NULL) AND (@footnote2 > 0)) OR
					((@footnote3 IS NOT NULL) AND (@footnote3 > 0)))
			BEGIN
				IF (@footnote1 > 0)
				BEGIN
					EXEC @footnote1_id = get_footnote_id @footnote1
					IF (@footnote1_id > 0)
					BEGIN
						SET @filter_engine_footnote_id = NULL
						SELECT @filter_engine_footnote_id = filter_engine_footnote_id
							FROM wix_filter_engine_footnote
							WHERE filter_engine_id = @filter_engine_id
								AND footnote_id = @footnote1_id
						IF (@filter_engine_footnote_id IS NULL)
							INSERT INTO wix_filter_engine_footnote (filter_engine_id, footnote_id)
								VALUES (@filter_engine_id, @footnote1_id)
					END				
				END
				IF (@footnote2 > 0)
				BEGIN
					EXEC @footnote2_id = get_footnote_id @footnote2
					IF (@footnote2_id > 0)
					BEGIN
						SET @filter_engine_footnote_id = NULL
						SELECT @filter_engine_footnote_id = filter_engine_footnote_id
							FROM wix_filter_engine_footnote
							WHERE filter_engine_id = @filter_engine_id
								AND footnote_id = @footnote2_id
						IF (@filter_engine_footnote_id IS NULL)
							INSERT INTO wix_filter_engine_footnote (filter_engine_id, footnote_id)
								VALUES (@filter_engine_id, @footnote2_id)				
					END				
				END
				IF (@footnote3 > 0)
				BEGIN
					EXEC @footnote3_id = get_footnote_id @footnote3
					IF (@footnote3_id > 0)
					BEGIN
						SET @filter_engine_footnote_id = NULL
						SELECT @filter_engine_footnote_id = filter_engine_footnote_id
							FROM wix_filter_engine_footnote
							WHERE filter_engine_id = @filter_engine_id
								AND footnote_id = @footnote3_id
						IF (@filter_engine_footnote_id IS NULL)
							INSERT INTO wix_filter_engine_footnote (filter_engine_id, footnote_id)
								VALUES (@filter_engine_id, @footnote3_id)				
					END				
				END
			END
			IF (((@additional_info IS NOT NULL) AND (@additional_info <> '')) OR ((@year IS NOT NULL) AND (@year > 0)))
			   EXEC @filter_engine_comment_id = get_comment_id @additional_info, @filter_engine_id, @year
		END			
		RETURN @filter_engine_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_filter_id]
(	
	@filter_number NVARCHAR(100)
)
AS
DECLARE @filter_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
		SELECT @filter_id = filter_id
			FROM wix_filters
			WHERE (LTRIM(RTRIM(@filter_number)) = filter_number_trim) 
		IF (@filter_id IS NOT NULL)
			RETURN @filter_id
		RETURN -1 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_media_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[get_filter_media_id]
(	
	@filter_media_abbr NVARCHAR(10)
)
AS
DECLARE @filter_media_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF ((@filter_media_abbr IS NULL) OR (@filter_media_abbr = ''))
 			RETURN -1 		
		SELECT @filter_media_id = media_id
			FROM wix_filter_medias
			WHERE UPPER(media_abbr) = UPPER(@filter_media_abbr);
		IF (@filter_media_id IS NULL)
		BEGIN
			INSERT INTO wix_filter_medias (media_name, media_abbr)
			VALUES (@filter_media_abbr, @filter_media_abbr)
			RETURN IDENT_CURRENT ('wix_filter_medias')
		END
		RETURN @filter_media_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_service_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[get_filter_service_id]
(	
	@filter_service_abbr NVARCHAR(10)
)
AS
DECLARE @filter_service_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY                                                          
		IF ((@filter_service_abbr IS NULL) OR (@filter_service_abbr = ''))
			RETURN -1
		SELECT @filter_service_id = service_id
			FROM wix_filter_services
			WHERE UPPER(service_abbr) = UPPER(@filter_service_abbr);
		IF (@filter_service_id IS NULL)
		BEGIN
			INSERT INTO wix_filter_services (service_name, service_abbr)
			VALUES (@filter_service_abbr, @filter_service_abbr)
			RETURN IDENT_CURRENT ('wix_filter_services')
		END
		RETURN @filter_service_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_shape_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[get_filter_shape_id]
(	
	@filter_shape_abbr NVARCHAR(10)
)
AS
DECLARE @filter_shape_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@filter_shape_abbr IS NULL) OR (@filter_shape_abbr = '')
  		RETURN -1
		SELECT @filter_shape_id = shape_id
			FROM wix_filter_shapes
			WHERE UPPER(shape_abbr) = UPPER(@filter_shape_abbr);
		IF (@filter_shape_id IS NULL)
		BEGIN
			INSERT INTO wix_filter_shapes (shape_name,shape_abbr)
			VALUES (@filter_shape_abbr, @filter_shape_abbr)
			RETURN IDENT_CURRENT ('wix_filter_shapes')
		END
		RETURN @filter_shape_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_style_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[get_filter_style_id]
(	
	@filter_style_abbr NVARCHAR(10)
)
AS
DECLARE @filter_style_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@filter_style_abbr IS NULL) OR (@filter_style_abbr = '')
  		RETURN -1
		SELECT @filter_style_id = style_id
			FROM wix_filter_styles
			WHERE UPPER(style_abbr) = UPPER(@filter_style_abbr);
		IF (@filter_style_id IS NULL)
		BEGIN
			INSERT INTO wix_filter_styles (style_name, style_abbr)
			VALUES (@filter_style_abbr, @filter_style_abbr)
			RETURN IDENT_CURRENT ('wix_filter_styles')
		END
		RETURN @filter_style_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_filter_type_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_filter_type_id]
(	
	@filter_type_abbr NVARCHAR(10)
)
AS
DECLARE @filter_type_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY                                                          
		IF ((@filter_type_abbr IS NULL) OR (@filter_type_abbr = ''))
			RETURN -1
		SELECT @filter_type_id = type_id
			FROM wix_filter_types
			WHERE UPPER(type_abbr) = UPPER(@filter_type_abbr);
		IF (@filter_type_id IS NULL)
		BEGIN
			INSERT INTO wix_filter_types (type_name, type_abbr)
			VALUES (@filter_type_abbr, @filter_type_abbr)
			RETURN IDENT_CURRENT ('wix_filter_types')
		END
		RETURN @filter_type_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_footnote_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_footnote_id]
(	
	@org_footnote_id INT
)
AS
DECLARE @footnote_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
		SELECT @footnote_id = footnote_id
			FROM wix_footnotes
			WHERE org_footnote_id = @org_footnote_id 
		IF (@footnote_id IS NOT NULL)
			RETURN @footnote_id
		RETURN -1 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_make_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_make_id]
(	
	@vehicle_id INT,
	@make_name NVARCHAR(100)
)
AS
DECLARE @make_id INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@vehicle_id IS NULL)
	    RAISERROR(
  	    'Procedure get_make_id error, vehicle_id NULL',
    	  10,
      	10
    	);
  	IF ((@make_name IS NULL) OR (@make_name = ''))
 			RETURN -1 		
		SELECT @make_id = make_id
			FROM wix_makes
			WHERE (UPPER(make_name) = UPPER(@make_name)) AND (vehicle_id = @vehicle_id);
		IF (@make_id IS NULL)
		BEGIN
			INSERT INTO wix_makes (make_name, vehicle_id)
			VALUES (@make_name, @vehicle_id)
			RETURN IDENT_CURRENT ('wix_makes')
		END
		RETURN @make_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[get_model_id]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[get_model_id]
(	
	@make_id INT,
	@model_name NVARCHAR(100),
	@model_year INT
)
AS
DECLARE @model_id INT;
DECLARE @year_from INT;
DECLARE @year_to INT;
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
BEGIN
  BEGIN TRY
  	IF (@make_id IS NULL)
	    RAISERROR(
  	    'Procedure get_model_id error, make_id NULL',
    	  10,
      	10
    	);
  	IF ((@model_name IS NULL) OR (@model_name = ''))
 			RETURN -1 		
		SELECT @model_id = model_id, @year_from = model_year_from, @year_to = model_year_to
			FROM wix_models
			WHERE (UPPER(model_name) = UPPER(@model_name)) AND (make_id = @make_id);
		IF (@model_id IS NULL)
		BEGIN
			INSERT INTO wix_models (model_name, model_year_from, model_year_to, make_id)
			VALUES (@model_name, @model_year, @model_year, @make_id)
			SET @model_id = IDENT_CURRENT ('wix_models')
		END
		IF (@model_year IS NOT NULL)
		BEGIN
			IF ((@year_from IS NULL) OR (@year_from > @model_year))
				UPDATE wix_models SET model_year_from = @model_year
				WHERE model_id = @model_id
			IF ((@year_to IS NULL) OR (@year_to < @model_year))
				UPDATE wix_models SET model_year_to = @model_year
				WHERE model_id = @model_id
		END 
		RETURN @model_id 
  END TRY
  BEGIN CATCH
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN -1              
END

GO
/****** Object:  StoredProcedure [dbo].[wix_atv_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_atv_import]
(
	@vehicle_id INT,
	@start_row INT,
	@end_row INT
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @year_name INT;
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_engine_id INT;
DECLARE @exception1 NVARCHAR(100);
DECLARE @exception2 NVARCHAR(100);
DECLARE @exception3 NVARCHAR(100);
DECLARE @filter_number NVARCHAR(100);
DECLARE @comment1 NVARCHAR(500);
DECLARE @comment2 NVARCHAR(500);	
DECLARE @footnote1 INT; 
DECLARE @footnote2 INT; 
DECLARE @footnote3 INT; 
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE atv_import_cursor CURSOR FOR
			SELECT atv_make, atv_year, atv_model, atv_engine, atv_exception1, atv_exception2, atv_exception3, 
				atv_filter_number, atv_footnote1, atv_footnote2, atv_footnote3, atv_comment1, atv_comment2
      FROM (
				SELECT atv_make, atv_year, atv_model, atv_engine, atv_exception1, atv_exception2, atv_exception3, 
					atv_filter_number, ROW_NUMBER() OVER (ORDER BY atv_filter_number) AS row_num, 
					atv_footnote1, atv_footnote2, atv_footnote3, atv_comment1, atv_comment2 
      	FROM import_wix_atv
			) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN atv_import_cursor
		FETCH NEXT FROM atv_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
			@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_number <> 'NA') AND (@filter_number <> 'NS'))
			BEGIN
				IF (@engine_name IS NULL)
					SET @engine_name = '---'
				SET @make_name = REPLACE(@make_name, '+', ' ')
			  EXEC @make_id = get_make_id @vehicle_id, @make_name
			  IF (@make_id > 0)
			  BEGIN
			  	EXEC @model_id = get_model_id @make_id, @model_name, @year_name
			  	IF (@model_id > 0)
			  	BEGIN
			  		EXEC @engine_id = get_engine_id @vehicle_id, @model_id, @engine_name, @year_name
				  	IF (@engine_id > 0)
				  	BEGIN
							EXEC @filter_id = get_filter_id @filter_number
					  	IF (@filter_id > 0)
					  	BEGIN
					  		EXEC @filter_engine_id = get_filter_engine_id @filter_id, @model_id, @engine_id, @year_name, @comment1, @comment2, @footnote1, @footnote2, @footnote3, @exception1, @exception2, @exception3
								IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
					  	END
				  	END
			  	END
      	END
      END
			FETCH NEXT FROM atv_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
				@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
				@comment1, @comment2
		END
		CLOSE atv_import_cursor
		DEALLOCATE atv_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE atv_import_cursor
		DEALLOCATE atv_import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[wix_bus_track_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_bus_track_import]
(
	@vehicle_id INT,
	@start_row INT,
	@end_row INT
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @year_name INT;
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_engine_id INT;
DECLARE @exception1 NVARCHAR(100);
DECLARE @exception2 NVARCHAR(100);
DECLARE @exception3 NVARCHAR(100);
DECLARE @filter_number NVARCHAR(100);
DECLARE @comment1 NVARCHAR(500);
DECLARE @comment2 NVARCHAR(500);	
DECLARE @footnote1 INT; 
DECLARE @footnote2 INT; 
DECLARE @footnote3 INT; 
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE bus_track_import_cursor CURSOR FOR
			SELECT bus_track_make, bus_track_year, bus_track_model, bus_track_engine, bus_track_exception1, 
				bus_track_exception2, bus_track_exception3, bus_track_filter_number, bus_track_footnote1, 
				bus_track_footnote2, bus_track_footnote3, bus_track_comment1, bus_track_comment2
      FROM (
      	SELECT bus_track_make, bus_track_year, bus_track_model, bus_track_engine, bus_track_exception1, 
					bus_track_exception2, bus_track_exception3, bus_track_filter_number, 
					ROW_NUMBER() OVER (ORDER BY bus_track_filter_number) AS row_num, bus_track_footnote1, 
					bus_track_footnote2, bus_track_footnote3, bus_track_comment1, bus_track_comment2
      	FROM import_wix_bus_track
			) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN bus_track_import_cursor
		FETCH NEXT FROM bus_track_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
			@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_number <> 'NA') AND (@filter_number <> 'NS'))
			BEGIN
				IF (@engine_name IS NULL)
					SET @engine_name = '---'
				SET @make_name = REPLACE(@make_name, '+', ' ')
			  EXEC @make_id = get_make_id @vehicle_id, @make_name
			  IF (@make_id > 0)
			  BEGIN
			  	EXEC @model_id = get_model_id @make_id, @model_name, @year_name
			  	IF (@model_id > 0)
			  	BEGIN
			  		EXEC @engine_id = get_engine_id @vehicle_id, @model_id, @engine_name, @year_name
				  	IF (@engine_id > 0)
				  	BEGIN
							EXEC @filter_id = get_filter_id @filter_number
					  	IF (@filter_id > 0)
					  	BEGIN
					  		EXEC @filter_engine_id = get_filter_engine_id @filter_id, @model_id, @engine_id, @year_name, @comment1, @comment2, @footnote1, @footnote2, @footnote3, @exception1, @exception2, @exception3
								IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
					  	END
				  	END
			  	END
      	END
      END
			FETCH NEXT FROM bus_track_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
				@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
				@comment1, @comment2
		END
		CLOSE bus_track_import_cursor                  
		DEALLOCATE bus_track_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE bus_track_import_cursor
		DEALLOCATE bus_track_import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[wix_filters_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_filters_import]
AS
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @filter_number NVARCHAR(100);
DECLARE @filter_type NVARCHAR(10);
DECLARE @filter_service NVARCHAR(10);
DECLARE @filter_media NVARCHAR(10);
DECLARE @filter_height DECIMAL(18,4);
DECLARE @filter_width DECIMAL(18,4);
DECLARE @filter_length DECIMAL(18,4);
DECLARE @filter_outside_dia_top DECIMAL(18,4);
DECLARE @filter_outside_dia_bottom DECIMAL(18,4);
DECLARE @filter_inside_dia_top DECIMAL(18,4);
DECLARE @filter_inside_dia_bottom DECIMAL(18,4);
DECLARE @filter_cubic_feet_per_minute INT;
DECLARE @filter_micron INT;
DECLARE @filter_thread_size NVARCHAR(80);
DECLARE @filter_ends NVARCHAR(1);
DECLARE @filter_fins BIT;
DECLARE @filter_oval_shaped BIT;
DECLARE @filter_shape_desc NVARCHAR(80);
DECLARE @filter_inlet NVARCHAR(80);
DECLARE @filter_outlet NVARCHAR(80);
DECLARE @filter_vapor NVARCHAR(80);
DECLARE @filter_threads NVARCHAR(80);
DECLARE @filter_bpvs NVARCHAR(80);
DECLARE @filter_adbv BIT;
DECLARE @filter_pressure_release BIT;
DECLARE @filter_stand_pipe BIT;
DECLARE @filter_anti_siphon_valve BIT;
DECLARE @filter_beta_ratio NVARCHAR(80);
DECLARE @filter_tube_layout NVARCHAR(80);
DECLARE @filter_drain BIT;
DECLARE @filter_burst_pressure INT;
DECLARE @filter_flow_rate NVARCHAR(80);
DECLARE @filter_illustration NVARCHAR(80);
DECLARE @filter_style NVARCHAR(10);
DECLARE @filter_principle_applications NVARCHAR(500);	
DECLARE @filter_service_id INT;
DECLARE @filter_type_id INT;
DECLARE @filter_style_id INT;
DECLARE @filter_media_id INT;
DECLARE @filter_shape_id INT;
DECLARE @filter_id INT;
BEGIN
  BEGIN TRY
		BEGIN TRANSACTION  
		DECLARE filters_import_cursor CURSOR FOR
			SELECT DISTINCT filter_number, filter_type, filter_service, filter_media, filter_height, 
				filter_width, filter_length, filter_outside_dia_top, filter_outside_dia_bottom, 
				filter_inside_dia_top, filter_inside_dia_bottom, filter_cubic_feet_per_minute, 
				filter_micron, filter_thread_size, filter_ends, dbo.convert_char_to_bool(filter_fins), 
				dbo.convert_char_to_bool(filter_oval_shaped), filter_shape_desc, filter_inlet, filter_outlet, 
				filter_vapor, filter_threads, filter_bpvs, dbo.convert_char_to_bool(filter_adbv), 
				dbo.convert_char_to_bool(filter_pressure_release), dbo.convert_char_to_bool(filter_stand_pipe), 
				dbo.convert_char_to_bool(filter_anti_siphon_valve), filter_beta_ratio, filter_tube_layout, 
				dbo.convert_char_to_bool(filter_drain), filter_burst_pressure, 
				filter_flow_rate, filter_illustration, filter_style, filter_principle_applications
      FROM import_wix_filters
      WHERE filter_id >= 63922
		OPEN filters_import_cursor
		FETCH NEXT FROM filters_import_cursor INTO @filter_number, @filter_type, @filter_service, 
				@filter_media, @filter_height, @filter_width, @filter_length, @filter_outside_dia_top, @filter_outside_dia_bottom, 
				@filter_inside_dia_top, @filter_inside_dia_bottom, @filter_cubic_feet_per_minute, 
				@filter_micron, @filter_thread_size, @filter_ends, @filter_fins, @filter_oval_shaped, 
				@filter_shape_desc, @filter_inlet, @filter_outlet, @filter_vapor, @filter_threads, @filter_bpvs, 
  			@filter_adbv, @filter_pressure_release, @filter_stand_pipe, @filter_anti_siphon_valve, 
				@filter_beta_ratio, @filter_tube_layout, @filter_drain, @filter_burst_pressure, 
				@filter_flow_rate, @filter_illustration, @filter_style, @filter_principle_applications
		WHILE @@FETCH_STATUS = 0
		BEGIN
			EXEC @filter_media_id = get_filter_media_id @filter_media
			IF (@filter_media_id = -1)
				SET @filter_media_id = NULL			
			EXEC @filter_type_id = get_filter_type_id @filter_service
			IF (@filter_type_id = -1)
				SET @filter_type_id = NULL			
			EXEC @filter_service_id = get_filter_service_id @filter_type
			IF (@filter_service_id = -1)
				SET @filter_service_id = NULL			
			EXEC @filter_style_id = get_filter_style_id @filter_style
			IF (@filter_style_id = -1)
				SET @filter_style_id = NULL			
			EXEC @filter_shape_id = get_filter_shape_id @filter_shape_desc
			IF (@filter_shape_id = -1)
				SET @filter_shape_id = NULL		
			SELECT @filter_id = filter_id
				FROM wix_filters
				WHERE filter_number = @filter_number
			IF (@filter_id IS NULL)	
			BEGIN
				INSERT INTO wix_filters (filter_number, filter_number_trim, filter_service_id, filter_type_id,   
						filter_media_id, filter_height, filter_width, filter_length, filter_outside_dia_top, filter_outside_dia_bottom, 
						filter_inside_dia_top, filter_inside_dia_bottom, filter_cubic_feet_per_minute, 
						filter_micron, filter_thread_size, filter_ends, filter_fins, filter_oval_shaped, 
						filter_shape_id, filter_inlet, filter_outlet, filter_vapor, filter_threads, filter_bpvs, 
  					filter_adbv, filter_pressure_release, filter_stand_pipe, filter_anti_siphon_valve, 
						filter_beta_ratio, filter_tube_layout, filter_drains, filter_burst_pressure, 
						filter_flow_rate, filter_image, filter_style_id, filter_principle_applications)
				VALUES (@filter_number, LTRIM(RTRIM(@filter_number)), @filter_service_id, @filter_type_id, 
						@filter_media_id, @filter_height, @filter_width, @filter_length, @filter_outside_dia_top, @filter_outside_dia_bottom, 
						@filter_inside_dia_top, @filter_inside_dia_bottom, @filter_cubic_feet_per_minute, 
						@filter_micron, @filter_thread_size, @filter_ends, @filter_fins, @filter_oval_shaped, 
						@filter_shape_id, @filter_inlet, @filter_outlet, @filter_vapor, @filter_threads, @filter_bpvs, 
  					@filter_adbv, @filter_pressure_release, @filter_stand_pipe, @filter_anti_siphon_valve, 
						@filter_beta_ratio, @filter_tube_layout, @filter_drain, @filter_burst_pressure, 
						@filter_flow_rate, @filter_illustration, @filter_style_id, @filter_principle_applications)
			END
			IF (@filter_id IS NOT NULL)
			BEGIN
				UPDATE wix_filters SET filter_number = @filter_number, filter_number_trim = LTRIM(RTRIM(@filter_number)), 
						filter_type_id = @filter_type_id, filter_service_id = @filter_service_id,  
						filter_media_id = @filter_media_id, filter_height = @filter_height, filter_width = @filter_width, 
						filter_length = @filter_length, filter_outside_dia_top = @filter_outside_dia_top, 
						filter_outside_dia_bottom = @filter_outside_dia_bottom, 
						filter_inside_dia_top = @filter_inside_dia_top, filter_inside_dia_bottom = @filter_inside_dia_bottom, 
						filter_cubic_feet_per_minute = @filter_cubic_feet_per_minute, 
						filter_micron = @filter_micron, filter_thread_size = @filter_thread_size, filter_ends = @filter_ends, 
						filter_fins = @filter_fins, filter_oval_shaped = @filter_oval_shaped, 
						filter_shape_id = @filter_shape_id, filter_inlet = @filter_inlet, filter_outlet = @filter_outlet, 
						filter_vapor = @filter_vapor, filter_threads = @filter_threads, filter_bpvs = @filter_bpvs, 
  					filter_adbv = @filter_adbv, filter_pressure_release = @filter_pressure_release, 
						filter_stand_pipe = @filter_stand_pipe, filter_anti_siphon_valve = @filter_anti_siphon_valve, 
						filter_beta_ratio = @filter_beta_ratio, filter_tube_layout = @filter_tube_layout, 
						filter_drains = @filter_drain, filter_burst_pressure = @filter_burst_pressure, 
						filter_flow_rate = @filter_flow_rate, filter_image = @filter_illustration, 
						filter_style_id = @filter_style_id, filter_principle_applications = @filter_principle_applications
					WHERE filter_id = @filter_id
			END			
			FETCH NEXT FROM filters_import_cursor INTO @filter_number, @filter_type, @filter_service, 
					@filter_media, @filter_height, @filter_width, @filter_length, @filter_outside_dia_top, @filter_outside_dia_bottom, 
					@filter_inside_dia_top, @filter_inside_dia_bottom, @filter_cubic_feet_per_minute, 
					@filter_micron, @filter_thread_size, @filter_ends, @filter_fins, @filter_oval_shaped, 
					@filter_shape_desc, @filter_inlet, @filter_outlet, @filter_vapor, @filter_threads, @filter_bpvs, 
  				@filter_adbv, @filter_pressure_release, @filter_stand_pipe, @filter_anti_siphon_valve, 
					@filter_beta_ratio, @filter_tube_layout, @filter_drain, @filter_burst_pressure, 
					@filter_flow_rate, @filter_illustration, @filter_style, @filter_principle_applications
		END
		CLOSE filters_import_cursor
		DEALLOCATE filters_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE filters_import_cursor
		DEALLOCATE filters_import_cursor
		IF @@TRANCOUNT > 0
			ROLLBACK TRANSACTION
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
	IF @@TRANCOUNT > 0
		COMMIT TRANSACTION
END
GO
/****** Object:  StoredProcedure [dbo].[wix_light_truck_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_light_truck_import]
(
	@vehicle_id INT,
	@start_row INT,
	@end_row INT
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @year_name INT;
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_engine_id INT;
DECLARE @exception1 NVARCHAR(100);
DECLARE @exception2 NVARCHAR(100);
DECLARE @exception3 NVARCHAR(100);
DECLARE @filter_number NVARCHAR(100);
DECLARE @comment1 NVARCHAR(500);
DECLARE @comment2 NVARCHAR(500);	
DECLARE @footnote1 INT; 
DECLARE @footnote2 INT; 
DECLARE @footnote3 INT; 
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE light_truck_import_cursor CURSOR FOR
			SELECT light_truck_make, light_truck_year, light_truck_model, light_truck_engine, light_truck_exception1, light_truck_exception2, 
            light_truck_exception3, light_truck_filter_number, light_truck_footnote1, light_truck_footnote2, light_truck_footnote3, 
            light_truck_comment1, light_truck_comment2
      FROM (
				SELECT light_truck_make, light_truck_year, light_truck_model, light_truck_engine, light_truck_exception1, light_truck_exception2, 
            light_truck_exception3, light_truck_filter_number, ROW_NUMBER() OVER (ORDER BY light_truck_filter_number) AS row_num, 
					light_truck_footnote1, light_truck_footnote2, light_truck_footnote3, light_truck_comment1, light_truck_comment2 
      	FROM import_wix_light_truck
			) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN light_truck_import_cursor
		FETCH NEXT FROM light_truck_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
			@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_number <> 'NA') AND (@filter_number <> 'NS'))
			BEGIN
				IF (@engine_name IS NULL)
					SET @engine_name = '---'
				SET @make_name = REPLACE(@make_name, '+', ' ')
			  EXEC @make_id = get_make_id @vehicle_id, @make_name
			  IF (@make_id > 0)
			  BEGIN
			  	EXEC @model_id = get_model_id @make_id, @model_name, @year_name
			  	IF (@model_id > 0)
			  	BEGIN
			  		EXEC @engine_id = get_engine_id @vehicle_id, @model_id, @engine_name, @year_name
				  	IF (@engine_id > 0)
				  	BEGIN
							EXEC @filter_id = get_filter_id @filter_number
					  	IF (@filter_id > 0)
					  	BEGIN
					  		EXEC @filter_engine_id = get_filter_engine_id @filter_id, @model_id, @engine_id, @year_name, @comment1, @comment2, @footnote1, @footnote2, @footnote3, @exception1, @exception2, @exception3
								IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
					  	END
				  	END
			  	END
      	END
      END
			FETCH NEXT FROM light_truck_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
				@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
				@comment1, @comment2
		END
		CLOSE light_truck_import_cursor
		DEALLOCATE light_truck_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE light_truck_import_cursor
		DEALLOCATE light_truck_import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END
GO
/****** Object:  StoredProcedure [dbo].[wix_motorcycle_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_motorcycle_import]
(
	@vehicle_id INT,
	@start_row INT,
	@end_row INT
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @year_name INT;
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_engine_id INT;
DECLARE @exception1 NVARCHAR(100);
DECLARE @exception2 NVARCHAR(100);
DECLARE @exception3 NVARCHAR(100);
DECLARE @comment1 NVARCHAR(500);
DECLARE @comment2 NVARCHAR(500);	
DECLARE @footnote1 INT; 
DECLARE @footnote2 INT; 
DECLARE @footnote3 INT; 
DECLARE @filter_number NVARCHAR(100);
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE motorcycle_import_cursor CURSOR FOR
			SELECT motorcycle_make, motorcycle_year, motorcycle_model, motorcycle_engine, motorcycle_exception1, 
				motorcycle_exception2, motorcycle_exception3, motorcycle_filter_number, motorcycle_footnote1, 
				motorcycle_footnote2, motorcycle_footnote3, motorcycle_comment1, motorcycle_comment2
      FROM (
				SELECT motorcycle_make, motorcycle_year, motorcycle_model, motorcycle_engine, motorcycle_exception1, 
					motorcycle_exception2, motorcycle_exception3, motorcycle_filter_number,
					ROW_NUMBER() OVER (ORDER BY motorcycle_filter_number) AS row_num, motorcycle_footnote1, 
				motorcycle_footnote2, motorcycle_footnote3, motorcycle_comment1, motorcycle_comment2
      	FROM import_wix_motorcycle
			) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN motorcycle_import_cursor
		FETCH NEXT FROM motorcycle_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
			@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_number <> 'NA') AND (@filter_number <> 'NS'))
			BEGIN
				IF (@engine_name IS NULL)
					SET @engine_name = '---'
				SET @make_name = REPLACE(@make_name, '+', ' ')
			  EXEC @make_id = get_make_id @vehicle_id, @make_name
			  IF (@make_id > 0)
			  BEGIN
			  	EXEC @model_id = get_model_id @make_id, @model_name, @year_name
			  	IF (@model_id > 0)
			  	BEGIN
			  		EXEC @engine_id = get_engine_id @vehicle_id, @model_id, @engine_name, @year_name
				  	IF (@engine_id > 0)
				  	BEGIN
							EXEC @filter_id = get_filter_id @filter_number
					  	IF (@filter_id > 0)
					  	BEGIN
					  		EXEC @filter_engine_id = get_filter_engine_id @filter_id, @model_id, @engine_id, @year_name, @comment1, @comment2, @footnote1, @footnote2, @footnote3, @exception1, @exception2, @exception3
								IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
					  	END
				  	END
			  	END
      	END
      END
			FETCH NEXT FROM motorcycle_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
				@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		END
		CLOSE motorcycle_import_cursor
		DEALLOCATE motorcycle_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE motorcycle_import_cursor
		DEALLOCATE motorcycle_import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[wix_new_filters_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_new_filters_import]
AS
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @filter_number NVARCHAR(100);
DECLARE @filter_type NVARCHAR(10);
DECLARE @filter_service NVARCHAR(10);
DECLARE @filter_media NVARCHAR(10);
DECLARE @filter_height DECIMAL(18,4);
DECLARE @filter_width DECIMAL(18,4);
DECLARE @filter_length DECIMAL(18,4);
DECLARE @filter_outside_dia_top DECIMAL(18,4);
DECLARE @filter_outside_dia_bottom DECIMAL(18,4);
DECLARE @filter_inside_dia_top DECIMAL(18,4);
DECLARE @filter_inside_dia_bottom DECIMAL(18,4);
DECLARE @filter_cubic_feet_per_minute INT;
DECLARE @filter_micron INT;
DECLARE @filter_thread_size NVARCHAR(80);
DECLARE @filter_ends NVARCHAR(1);
DECLARE @filter_fins BIT;
DECLARE @filter_oval_shaped BIT;
DECLARE @filter_shape_desc NVARCHAR(80);
DECLARE @filter_inlet NVARCHAR(80);
DECLARE @filter_outlet NVARCHAR(80);
DECLARE @filter_vapor NVARCHAR(80);
DECLARE @filter_threads NVARCHAR(80);
DECLARE @filter_bpvs NVARCHAR(80);
DECLARE @filter_adbv BIT;
DECLARE @filter_pressure_release BIT;
DECLARE @filter_stand_pipe BIT;
DECLARE @filter_anti_siphon_valve BIT;
DECLARE @filter_beta_ratio NVARCHAR(80);
DECLARE @filter_tube_layout NVARCHAR(80);
DECLARE @filter_drain BIT;
DECLARE @filter_burst_pressure INT;
DECLARE @filter_flow_rate NVARCHAR(80);
DECLARE @filter_illustration NVARCHAR(80);
DECLARE @filter_style NVARCHAR(10);
DECLARE @filter_principle_applications NVARCHAR(500);	
DECLARE @filter_service_id INT;
DECLARE @filter_type_id INT;
DECLARE @filter_style_id INT;
DECLARE @filter_media_id INT;
DECLARE @filter_shape_id INT;
DECLARE @filter_id INT;
BEGIN
  BEGIN TRY
		BEGIN TRANSACTION  
		DECLARE filters_import_cursor CURSOR FOR
			SELECT DISTINCT filter_number, filter_type, filter_service, filter_media, filter_height, 
				filter_width, filter_length, filter_outside_dia_top, filter_outside_dia_bottom, 
				filter_inside_dia_top, filter_inside_dia_bottom, filter_cubic_feet_per_minute, 
				filter_micron, filter_thread_size, filter_ends, dbo.convert_char_to_bool(filter_fins), 
				dbo.convert_char_to_bool(filter_oval_shaped), filter_shape_desc, filter_inlet, filter_outlet, 
				filter_vapor, filter_threads, filter_bpvs, dbo.convert_char_to_bool(filter_adbv), 
				dbo.convert_char_to_bool(filter_pressure_release), dbo.convert_char_to_bool(filter_stand_pipe), 
				dbo.convert_char_to_bool(filter_anti_siphon_valve), filter_beta_ratio, filter_tube_layout, 
				dbo.convert_char_to_bool(filter_drain), filter_burst_pressure, 
				filter_flow_rate, filter_illustration, filter_style, filter_principle_applications
      FROM import_wix_filters
      WHERE filter_number NOT IN (SELECT filter_number FROM wix_filters)
		OPEN filters_import_cursor
		FETCH NEXT FROM filters_import_cursor INTO @filter_number, @filter_type, @filter_service, 
				@filter_media, @filter_height, @filter_width, @filter_length, @filter_outside_dia_top, @filter_outside_dia_bottom, 
				@filter_inside_dia_top, @filter_inside_dia_bottom, @filter_cubic_feet_per_minute, 
				@filter_micron, @filter_thread_size, @filter_ends, @filter_fins, @filter_oval_shaped, 
				@filter_shape_desc, @filter_inlet, @filter_outlet, @filter_vapor, @filter_threads, @filter_bpvs, 
  			@filter_adbv, @filter_pressure_release, @filter_stand_pipe, @filter_anti_siphon_valve, 
				@filter_beta_ratio, @filter_tube_layout, @filter_drain, @filter_burst_pressure, 
				@filter_flow_rate, @filter_illustration, @filter_style, @filter_principle_applications
		WHILE @@FETCH_STATUS = 0
		BEGIN
			EXEC @filter_media_id = get_filter_media_id @filter_media
			IF (@filter_media_id = -1)
				SET @filter_media_id = NULL			
			EXEC @filter_type_id = get_filter_type_id @filter_service
			IF (@filter_type_id = -1)
				SET @filter_type_id = NULL			
			EXEC @filter_service_id = get_filter_service_id @filter_type
			IF (@filter_service_id = -1)
				SET @filter_service_id = NULL			
			EXEC @filter_style_id = get_filter_style_id @filter_style
			IF (@filter_style_id = -1)
				SET @filter_style_id = NULL			
			EXEC @filter_shape_id = get_filter_shape_id @filter_shape_desc
			IF (@filter_shape_id = -1)
				SET @filter_shape_id = NULL		
			SELECT @filter_id = filter_id
				FROM wix_filters
				WHERE filter_number = @filter_number
			IF (@filter_id IS NULL)	
			BEGIN
				INSERT INTO wix_filters (filter_number, filter_number_trim, filter_service_id, filter_type_id,   
						filter_media_id, filter_height, filter_width, filter_length, filter_outside_dia_top, filter_outside_dia_bottom, 
						filter_inside_dia_top, filter_inside_dia_bottom, filter_cubic_feet_per_minute, 
						filter_micron, filter_thread_size, filter_ends, filter_fins, filter_oval_shaped, 
						filter_shape_id, filter_inlet, filter_outlet, filter_vapor, filter_threads, filter_bpvs, 
  					filter_adbv, filter_pressure_release, filter_stand_pipe, filter_anti_siphon_valve, 
						filter_beta_ratio, filter_tube_layout, filter_drains, filter_burst_pressure, 
						filter_flow_rate, filter_image, filter_style_id, filter_principle_applications)
				VALUES (@filter_number, LTRIM(RTRIM(@filter_number)), @filter_service_id, @filter_type_id, 
						@filter_media_id, @filter_height, @filter_width, @filter_length, @filter_outside_dia_top, @filter_outside_dia_bottom, 
						@filter_inside_dia_top, @filter_inside_dia_bottom, @filter_cubic_feet_per_minute, 
						@filter_micron, @filter_thread_size, @filter_ends, @filter_fins, @filter_oval_shaped, 
						@filter_shape_id, @filter_inlet, @filter_outlet, @filter_vapor, @filter_threads, @filter_bpvs, 
  					@filter_adbv, @filter_pressure_release, @filter_stand_pipe, @filter_anti_siphon_valve, 
						@filter_beta_ratio, @filter_tube_layout, @filter_drain, @filter_burst_pressure, 
						@filter_flow_rate, @filter_illustration, @filter_style_id, @filter_principle_applications)
			END
			IF (@filter_id IS NOT NULL)
			BEGIN
				UPDATE wix_filters SET filter_number = @filter_number, filter_number_trim = LTRIM(RTRIM(@filter_number)), 
						filter_type_id = @filter_type_id, filter_service_id = @filter_service_id,  
						filter_media_id = @filter_media_id, filter_height = @filter_height, filter_width = @filter_width, 
						filter_length = @filter_length, filter_outside_dia_top = @filter_outside_dia_top, 
						filter_outside_dia_bottom = @filter_outside_dia_bottom, 
						filter_inside_dia_top = @filter_inside_dia_top, filter_inside_dia_bottom = @filter_inside_dia_bottom, 
						filter_cubic_feet_per_minute = @filter_cubic_feet_per_minute, 
						filter_micron = @filter_micron, filter_thread_size = @filter_thread_size, filter_ends = @filter_ends, 
						filter_fins = @filter_fins, filter_oval_shaped = @filter_oval_shaped, 
						filter_shape_id = @filter_shape_id, filter_inlet = @filter_inlet, filter_outlet = @filter_outlet, 
						filter_vapor = @filter_vapor, filter_threads = @filter_threads, filter_bpvs = @filter_bpvs, 
  					filter_adbv = @filter_adbv, filter_pressure_release = @filter_pressure_release, 
						filter_stand_pipe = @filter_stand_pipe, filter_anti_siphon_valve = @filter_anti_siphon_valve, 
						filter_beta_ratio = @filter_beta_ratio, filter_tube_layout = @filter_tube_layout, 
						filter_drains = @filter_drain, filter_burst_pressure = @filter_burst_pressure, 
						filter_flow_rate = @filter_flow_rate, filter_image = @filter_illustration, 
						filter_style_id = @filter_style_id, filter_principle_applications = @filter_principle_applications
					WHERE filter_id = @filter_id
			END			
			FETCH NEXT FROM filters_import_cursor INTO @filter_number, @filter_type, @filter_service, 
					@filter_media, @filter_height, @filter_width, @filter_length, @filter_outside_dia_top, @filter_outside_dia_bottom, 
					@filter_inside_dia_top, @filter_inside_dia_bottom, @filter_cubic_feet_per_minute, 
					@filter_micron, @filter_thread_size, @filter_ends, @filter_fins, @filter_oval_shaped, 
					@filter_shape_desc, @filter_inlet, @filter_outlet, @filter_vapor, @filter_threads, @filter_bpvs, 
  				@filter_adbv, @filter_pressure_release, @filter_stand_pipe, @filter_anti_siphon_valve, 
					@filter_beta_ratio, @filter_tube_layout, @filter_drain, @filter_burst_pressure, 
					@filter_flow_rate, @filter_illustration, @filter_style, @filter_principle_applications
		END
		CLOSE filters_import_cursor
		DEALLOCATE filters_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE filters_import_cursor
		DEALLOCATE filters_import_cursor
		IF @@TRANCOUNT > 0
			ROLLBACK TRANSACTION
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
	IF @@TRANCOUNT > 0
		COMMIT TRANSACTION
END
GO
/****** Object:  StoredProcedure [dbo].[wix_off_highway_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_off_highway_import]
(
	@vehicle_id INT,
	@start_row INT,
	@end_row INT	
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @year_name INT;
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_engine_id INT;
DECLARE @exception1 NVARCHAR(100);
DECLARE @exception2 NVARCHAR(100);
DECLARE @exception3 NVARCHAR(100);
DECLARE @filter_number NVARCHAR(100);
DECLARE @comment1 NVARCHAR(500);
DECLARE @comment2 NVARCHAR(500);	
DECLARE @footnote1 INT; 
DECLARE @footnote2 INT; 
DECLARE @footnote3 INT; 
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE off_highway_import_cursor CURSOR FOR
			SELECT off_highway_make, off_highway_year, off_highway_model, off_highway_engine, 
				off_highway_exception1, off_highway_exception2, off_highway_exception3, off_highway_filter_number, 
				off_highway_footnote1, off_highway_footnote2, off_highway_footnote3, off_highway_comment1, 
				off_highway_comment2
      FROM (
				SELECT off_highway_make, off_highway_year, off_highway_model, off_highway_engine, 
					off_highway_exception1, off_highway_exception2, off_highway_exception3, off_highway_filter_number,
					ROW_NUMBER() OVER (ORDER BY off_highway_filter_number) AS row_num, 
					off_highway_footnote1, off_highway_footnote2, off_highway_footnote3, off_highway_comment1, 
					off_highway_comment2
    	  FROM import_wix_off_highway
			) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN off_highway_import_cursor
		FETCH NEXT FROM off_highway_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
			@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_number <> 'NA') AND (@filter_number <> 'NS'))
			BEGIN
				IF (@engine_name IS NULL)
					SET @engine_name = '---'
				SET @make_name = REPLACE(@make_name, '+', ' ')
			  EXEC @make_id = get_make_id @vehicle_id, @make_name
			  IF (@make_id > 0)
			  BEGIN
			  	EXEC @model_id = get_model_id @make_id, @model_name, @year_name
			  	IF (@model_id > 0)
			  	BEGIN
			  		EXEC @engine_id = get_engine_id @vehicle_id, @model_id, @engine_name, @year_name
				  	IF (@engine_id > 0)
				  	BEGIN
				  		EXEC @filter_id = get_filter_id @filter_number							
					  	IF (@filter_id > 0)
					  	BEGIN
					  		EXEC @filter_engine_id = get_filter_engine_id @filter_id, @model_id, @engine_id, @year_name, @comment1, @comment2, @footnote1, @footnote2, @footnote3, @exception1, @exception2, @exception3
								IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
					  	END
				  	END
			  	END
      	END
      END
			FETCH NEXT FROM off_highway_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
				@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
				@comment1, @comment2
		END
		CLOSE off_highway_import_cursor
		DEALLOCATE off_highway_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE off_highway_import_cursor
		DEALLOCATE off_highway_import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  StoredProcedure [dbo].[wix_passenger_import]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[wix_passenger_import]
(
	@vehicle_id INT,
	@start_row INT,
	@end_row INT	
)
AS
DECLARE @make_name NVARCHAR(100);
DECLARE @year_name INT;
DECLARE @model_name NVARCHAR(100);
DECLARE @engine_name NVARCHAR(100);
DECLARE @make_id INT;
DECLARE @model_id INT;
DECLARE @engine_id INT;
DECLARE @filter_id INT;
DECLARE @filter_engine_id INT;
DECLARE @exception1 NVARCHAR(100);
DECLARE @exception2 NVARCHAR(100);
DECLARE @exception3 NVARCHAR(100);
DECLARE @filter_number NVARCHAR(100);
DECLARE @comment1 NVARCHAR(500);
DECLARE @comment2 NVARCHAR(500);	
DECLARE @footnote1 INT; 
DECLARE @footnote2 INT; 
DECLARE @footnote3 INT; 
DECLARE @error_message NVARCHAR(2048);
DECLARE @error_severity INT;
DECLARE @error_state INT;
DECLARE @rows_affected INT;
BEGIN
	SET @rows_affected = 0;
  BEGIN TRY
		DECLARE passenger_import_cursor CURSOR FOR
			SELECT passenger_make, passenger_year, passenger_model, passenger_engine, passenger_exception1, 
				passenger_exception2, passenger_exception3, passenger_filter_number, passenger_footnote1, 
				passenger_footnote2, passenger_footnote3, passenger_comment1, passenger_comment2
      FROM (
				SELECT passenger_make, passenger_year, passenger_model, passenger_engine, passenger_exception1, 
					passenger_exception2, passenger_exception3, passenger_filter_number, 
					ROW_NUMBER() OVER (ORDER BY passenger_id) AS row_num, passenger_footnote1, 
				passenger_footnote2, passenger_footnote3, passenger_comment1, passenger_comment2
      	FROM import_wix_passenger
      ) AS derived_import_table
			WHERE derived_import_table.row_num BETWEEN @start_row AND @end_row
		OPEN passenger_import_cursor
		FETCH NEXT FROM passenger_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
			@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
			@comment1, @comment2
		WHILE @@FETCH_STATUS = 0
		BEGIN
			IF ((@filter_number <> 'NA') AND (@filter_number <> 'NS'))
			BEGIN
			  EXEC @make_id = get_make_id @vehicle_id, @make_name
			  IF (@make_id > 0)
			  BEGIN
			  	EXEC @model_id = get_model_id @make_id, @model_name, @year_name
			  	IF (@model_id > 0)
			  	BEGIN
			  		EXEC @engine_id = get_engine_id @vehicle_id, @model_id, @engine_name, @year_name
				  	IF (@engine_id > 0)
				  	BEGIN
							EXEC @filter_id = get_filter_id @filter_number
					  	IF (@filter_id > 0)
					  	BEGIN
					  		EXEC @filter_engine_id = get_filter_engine_id @filter_id, @model_id, @engine_id, @year_name, @comment1, @comment2, @footnote1, @footnote2, @footnote3, @exception1, @exception2, @exception3
								IF (@filter_engine_id > 0)
									SET @rows_affected = @rows_affected + 1 	 
				      	ELSE
  				    		PRINT 'filter engine null, ' + @filter_id				  						  	
					  	END
			      	ELSE
  			    		PRINT 'filter null, ' + @filter_number				  						  	
				  	END
		      	ELSE
  		    		PRINT 'engine null, ' + @engine_name				  	
			  	END
	      	ELSE
  	    		PRINT 'model null, ' + @model_name
      	END
      	ELSE
      		PRINT 'make null, ' + @make_name
      END
			FETCH NEXT FROM passenger_import_cursor INTO @make_name, @year_name, @model_name, @engine_name, 
				@exception1, @exception2, @exception3, @filter_number, @footnote1, @footnote2, @footnote3, 
				@comment1, @comment2
		END
		CLOSE passenger_import_cursor
		DEALLOCATE passenger_import_cursor
  END TRY
  BEGIN CATCH
		CLOSE passenger_import_cursor
		DEALLOCATE passenger_import_cursor
    SELECT 
      @error_message = ERROR_MESSAGE(),
      @error_severity = ERROR_SEVERITY(),
      @error_state = ERROR_STATE();				
    RAISERROR(
      @error_message,
      @error_severity,
      @error_state
    );
  END CATCH
  RETURN @rows_affected              
END

GO
/****** Object:  UserDefinedFunction [dbo].[convert_char_to_bool]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[convert_char_to_bool]
(
	@value_to_convert NVARCHAR(1)
)
RETURNS BIT
AS
BEGIN
	IF @value_to_convert = 'T'
		RETURN 1
	RETURN 0
END

GO
/****** Object:  UserDefinedFunction [dbo].[filtron_convert_char_to_bool]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[filtron_convert_char_to_bool]
(
	@value_to_convert NVARCHAR(5)
)
RETURNS BIT
AS
BEGIN
	IF (UPPER(@value_to_convert) LIKE 'YES')
		RETURN 1
	RETURN 0
END

GO
/****** Object:  UserDefinedFunction [dbo].[filtron_get_engine_year_from]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[filtron_get_engine_year_from]
(
	@engine_years NVARCHAR(100)
)
RETURNS INT
AS
BEGIN
	DECLARE @year_and_month NVARCHAR(100)
	DECLARE @year_and_month_int INT
	IF ((@engine_years IS NOT NULL) AND (@engine_years <> ''))
	BEGIN
		SET @year_and_month = LEFT(@engine_years, NULLIF(CHARINDEX('->', @engine_years), 0) - 1)
		IF (CHARINDEX('-', @year_and_month) > 0)
			RETURN LEFT(@engine_years, NULLIF(CHARINDEX('-', @engine_years), 0) - 1)
		IF (CHARINDEX('/', @year_and_month) > 0)
			SET @year_and_month = RIGHT(@year_and_month, LEN(@year_and_month) - NULLIF(CHARINDEX('/', @year_and_month), 0))
		IF ((@year_and_month IS NOT NULL) AND (@year_and_month <> ''))
		BEGIN
			SET @year_and_month_int = CAST(@year_and_month AS INT)
			IF (@year_and_month_int <= 40)
				RETURN (2000 + @year_and_month_int)
			ELSE 
				RETURN (1900 + @year_and_month_int)
		END
	END
  RETURN -1              
END

GO
/****** Object:  UserDefinedFunction [dbo].[filtron_get_engine_year_to]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[filtron_get_engine_year_to]
(
	@engine_years NVARCHAR(100)
)
RETURNS INT
AS
BEGIN
	DECLARE @year_and_month NVARCHAR(100)
	DECLARE @year_and_month_int INT
	IF ((@engine_years IS NOT NULL) AND (@engine_years <> ''))
	BEGIN
		SET @year_and_month = RIGHT(@engine_years, LEN(@engine_years) - NULLIF(CHARINDEX('->', @engine_years), 0) - 1)
		IF (CHARINDEX('-', @year_and_month) > 0)
			RETURN LEFT(@engine_years, NULLIF(CHARINDEX('-', @engine_years), 0) - 1)
		IF (CHARINDEX('/', @year_and_month) > 0)
			SET @year_and_month = RIGHT(@year_and_month, LEN(@year_and_month) - NULLIF(CHARINDEX('/', @year_and_month), 0))
		IF ((@year_and_month IS NOT NULL) AND (@year_and_month <> ''))
		BEGIN
			SET @year_and_month_int = CAST(@year_and_month AS INT)
			IF (@year_and_month_int <= 40)
				RETURN (2000 + @year_and_month_int)
			ELSE 
				RETURN (1900 + @year_and_month_int)
		END
	END
  RETURN -1              
END

GO
/****** Object:  UserDefinedFunction [dbo].[get_engine_year_from]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[get_engine_year_from]
(
	@engine_years NVARCHAR(100)
)
RETURNS INT
AS
BEGIN
	DECLARE @year_and_month NVARCHAR(100)
	DECLARE @year_and_month_int INT
	IF ((@engine_years IS NOT NULL) AND (@engine_years <> ''))
	BEGIN
		SET @year_and_month = LEFT(@engine_years, NULLIF(CHARINDEX('->', @engine_years), 0) - 1)
		IF (CHARINDEX('-', @year_and_month) > 0)
			RETURN LEFT(@engine_years, NULLIF(CHARINDEX('-', @engine_years), 0) - 1)
		IF (CHARINDEX('/', @year_and_month) > 0)
			SET @year_and_month = RIGHT(@year_and_month, LEN(@year_and_month) - NULLIF(CHARINDEX('/', @year_and_month), 0))
		IF ((@year_and_month IS NOT NULL) AND (@year_and_month <> ''))
		BEGIN
			SET @year_and_month_int = CAST(@year_and_month AS INT)
			IF (@year_and_month_int <= 40)
				RETURN (2000 + @year_and_month_int)
			ELSE 
				RETURN (1900 + @year_and_month_int)
		END
	END
  RETURN -1              
END
GO
/****** Object:  UserDefinedFunction [dbo].[get_engine_year_to]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[get_engine_year_to]
(
	@engine_years NVARCHAR(100)
)
RETURNS INT
AS
BEGIN
	DECLARE @year_and_month NVARCHAR(100)
	DECLARE @year_and_month_int INT
	IF ((@engine_years IS NOT NULL) AND (@engine_years <> ''))
	BEGIN
		SET @year_and_month = RIGHT(@engine_years, LEN(@engine_years) - NULLIF(CHARINDEX('->', @engine_years), 0) - 1)
		IF (CHARINDEX('-', @year_and_month) > 0)
			RETURN LEFT(@engine_years, NULLIF(CHARINDEX('-', @engine_years), 0) - 1)
		IF (CHARINDEX('/', @year_and_month) > 0)
			SET @year_and_month = RIGHT(@year_and_month, LEN(@year_and_month) - NULLIF(CHARINDEX('/', @year_and_month), 0))
		IF ((@year_and_month IS NOT NULL) AND (@year_and_month <> ''))
		BEGIN
			SET @year_and_month_int = CAST(@year_and_month AS INT)
			IF (@year_and_month_int <= 40)
				RETURN (2000 + @year_and_month_int)
			ELSE 
				RETURN (1900 + @year_and_month_int)
		END
	END
  RETURN -1              
END
GO
/****** Object:  Table [dbo].[filtron_engine_models]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_engine_models](
	[engine_model_id] [int] IDENTITY(1,1) NOT NULL,
	[engine_model_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_e__engin__1F98B2C1]  DEFAULT (getdate()),
	[engine_model_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_e__engin__208CD6FA]  DEFAULT (getdate()),
	[engine_id] [int] NOT NULL,
	[model_id] [int] NOT NULL,
 CONSTRAINT [PK__filtron_engine_m__1EA48E88] PRIMARY KEY CLUSTERED 
(
	[engine_model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_engines]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_engines](
	[engine_id] [int] IDENTITY(1,1) NOT NULL,
	[engine_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_e__engin__1AD3FDA4]  DEFAULT (getdate()),
	[engine_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_e__engin__1BC821DD]  DEFAULT (getdate()),
	[engine_name] [nvarchar](100) NOT NULL,
	[engine_description] [nvarchar](255) NULL,
	[engine_cubic_capacity] [nvarchar](255) NULL,
	[engine_code] [nvarchar](255) NULL,
	[engine_horse_power] [nvarchar](255) NULL,
	[engine_year_from] [int] NULL,
	[engine_year_to] [int] NULL,
	[vehicle_id] [int] NOT NULL,
 CONSTRAINT [PK__filtron_engines__19DFD96B] PRIMARY KEY CLUSTERED 
(
	[engine_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_engine_comments]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_engine_comments](
	[filter_engine_comment_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_engine_comment_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__filte__7D63964E]  DEFAULT (getdate()),
	[filter_engine_comment_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__filte__7E57BA87]  DEFAULT (getdate()),
	[filter_engine_id] [int] NOT NULL,
	[filter_info_years] [nvarchar](255) NULL,
	[filter_info_description] [nvarchar](255) NULL,
 CONSTRAINT [PK__filtron_filter_e__7C6F7215] PRIMARY KEY CLUSTERED 
(
	[filter_engine_comment_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_engines]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_engines](
	[filter_engine_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_engine_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__filte__6AEFE058]  DEFAULT (getdate()),
	[filter_engine_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__filte__6BE40491]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[engine_id] [int] NOT NULL,
	[model_id] [int] NOT NULL,
	[filter_additional_info] [nvarchar](500) NULL,
	[filter_other_info] [nvarchar](255) NULL,
 CONSTRAINT [PK__filtron_filter_e__69FBBC1F] PRIMARY KEY CLUSTERED 
(
	[filter_engine_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_medias]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_medias](
	[media_id] [int] IDENTITY(1,1) NOT NULL,
	[media_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__media__2B0A656D]  DEFAULT (getdate()),
	[media_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__media__2BFE89A6]  DEFAULT (getdate()),
	[media_name] [nvarchar](100) NOT NULL,
	[media_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__filtron_filter_m__2A164134] PRIMARY KEY CLUSTERED 
(
	[media_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_shapes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_shapes](
	[shape_id] [int] IDENTITY(1,1) NOT NULL,
	[shape_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__shape__3493CFA7]  DEFAULT (getdate()),
	[shape_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__shape__3587F3E0]  DEFAULT (getdate()),
	[shape_name] [nvarchar](100) NOT NULL,
	[shape_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__filtron_filter_s__339FAB6E] PRIMARY KEY CLUSTERED 
(
	[shape_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_styles]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_styles](
	[style_id] [int] IDENTITY(1,1) NOT NULL,
	[style_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__style__2FCF1A8A]  DEFAULT (getdate()),
	[style_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__style__30C33EC3]  DEFAULT (getdate()),
	[style_name] [nvarchar](100) NOT NULL,
	[style_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__filtron_filter_s__2EDAF651] PRIMARY KEY CLUSTERED 
(
	[style_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_type_shapes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_type_shapes](
	[type_shape_id] [int] IDENTITY(1,1) NOT NULL,
	[type_shape_created] [datetime] NOT NULL,
	[type_shape_modified] [datetime] NOT NULL,
	[type_id] [int] NOT NULL,
	[shape_id] [int] NOT NULL,
	[dim_a_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_a__7EC1CEDB]  DEFAULT ((0)),
	[dim_b_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_b__7FB5F314]  DEFAULT ((0)),
	[dim_c_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_c__00AA174D]  DEFAULT ((0)),
	[dim_d_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_d__019E3B86]  DEFAULT ((0)),
	[dim_e_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_e__02925FBF]  DEFAULT ((0)),
	[dim_f_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_f__038683F8]  DEFAULT ((0)),
	[dim_g_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_g__047AA831]  DEFAULT ((0)),
	[dim_h_available] [bit] NULL CONSTRAINT [DF__filtron_f__dim_h__056ECC6A]  DEFAULT ((0)),
	[default_figure_link] [nvarchar](100) NULL,
	[dict_id] [int] NULL,
	[dict_kind] [int] NULL,
 CONSTRAINT [PK__filtron_filter_t__3864608B] PRIMARY KEY CLUSTERED 
(
	[type_shape_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filter_types]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_filter_types](
	[type_id] [int] IDENTITY(1,1) NOT NULL,
	[type_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__type___2645B050]  DEFAULT (getdate()),
	[type_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__type___2739D489]  DEFAULT (getdate()),
	[type_name] [nvarchar](100) NOT NULL,
	[type_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__filtron_filter_t__25518C17] PRIMARY KEY CLUSTERED 
(
	[type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_filters]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[filtron_filters](
	[filter_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__filte__46B27FE2]  DEFAULT (getdate()),
	[filter_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_f__filte__47A6A41B]  DEFAULT (getdate()),
	[filter_number] [nvarchar](100) NOT NULL,
	[filter_number_trim] [nvarchar](100) NOT NULL,
	[filter_type_id] [int] NOT NULL,
	[filter_media_id] [int] NULL,
	[filter_style_id] [int] NULL,
	[filter_shape_id] [int] NULL,
	[filter_by_pass_valve] [bit] NULL CONSTRAINT [DF__filtron_f__filte__0E04126B]  DEFAULT ((0)),
	[filter_anti_drain_valve] [bit] NULL CONSTRAINT [DF__filtron_f__filte__540C7B00]  DEFAULT ((0)),
	[filter_anti_siphon_valve] [bit] NULL CONSTRAINT [DF__filtron_f__filte__56E8E7AB]  DEFAULT ((0)),
	[filter_burst_pressure] [int] NULL,
	[filter_principle_applications] [nvarchar](max) NULL,
	[filter_image] [nvarchar](255) NULL,
	[filter_dim_a] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__0662F0A3]  DEFAULT ((0)),
	[filter_dim_b] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__075714DC]  DEFAULT ((0)),
	[filter_dim_c] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__084B3915]  DEFAULT ((0)),
	[filter_dim_d] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__093F5D4E]  DEFAULT ((0)),
	[filter_dim_e] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__0A338187]  DEFAULT ((0)),
	[filter_dim_f] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__0B27A5C0]  DEFAULT ((0)),
	[filter_dim_g] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__0C1BC9F9]  DEFAULT ((0)),
	[filter_dim_h] [decimal](18, 4) NOT NULL CONSTRAINT [DF__filtron_f__filte__0D0FEE32]  DEFAULT ((0)),
	[filter_wix_number] [nvarchar](100) NULL,
	[filter_wix_number_hd] [nvarchar](100) NULL,
	[filter_instruction] [varchar](50) NULL,
	[filter_number_org] [nvarchar](100) NULL,
	[filter_number_trim_org] [nvarchar](100) NULL,
	[filter_dim_a_text] [nvarchar](50) NULL,
	[filter_dim_b_text] [nvarchar](50) NULL,
	[filter_dim_c_text] [nvarchar](50) NULL,
	[filter_dim_d_text] [nvarchar](50) NULL,
	[filter_dim_e_text] [nvarchar](50) NULL,
	[filter_dim_f_text] [nvarchar](50) NULL,
	[filter_dim_g_text] [nvarchar](50) NULL,
	[filter_dim_h_text] [nvarchar](50) NULL,
 CONSTRAINT [PK__filtron_filters__45BE5BA9] PRIMARY KEY CLUSTERED 
(
	[filter_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[filtron_interchange_manufacturers]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_interchange_manufacturers](
	[manufacturer_id] [int] IDENTITY(1,1) NOT NULL,
	[manufacturer_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_i__manuf__5F7E2DAC]  DEFAULT (getdate()),
	[manufacturer_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_i__manuf__607251E5]  DEFAULT (getdate()),
	[manufacturer_name] [nvarchar](100) NOT NULL,
	[manufacturer_description] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK__filtron_intercha__5E8A0973] PRIMARY KEY CLUSTERED 
(
	[manufacturer_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_interchanges]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_interchanges](
	[interchange_id] [int] IDENTITY(1,1) NOT NULL,
	[interchange_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_i__inter__6442E2C9]  DEFAULT (getdate()),
	[interchange_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_i__inter__65370702]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[manufacturer_id] [int] NOT NULL,
	[foreign_filter_number] [nvarchar](255) NOT NULL,
	[foreign_filter_trim] [nvarchar](255) NOT NULL,
	[filter_is_oe] [bit] NULL CONSTRAINT [DF__filtron_i__filte__4A6E022D]  DEFAULT ((0)),
 CONSTRAINT [PK__filtron_intercha__634EBE90] PRIMARY KEY CLUSTERED 
(
	[interchange_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_logistics_info]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_logistics_info](
	[logistics_info_id] [int] IDENTITY(1,1) NOT NULL,
	[logistics_info_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_l__logis__4E3E9311]  DEFAULT (getdate()),
	[logistics_info_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_l__logis__4F32B74A]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[hd] [nvarchar](80) NULL,
	[min_ilosc_zam] [int] NULL,
	[ilosc_zg] [int] NULL,
	[ilosc_pal] [int] NULL,
	[kart_w] [int] NULL,
	[kart_h] [int] NULL,
	[kart_l] [int] NULL,
	[waga] [nvarchar](80) NULL,
	[kod_ean] [nvarchar](80) NULL,
 CONSTRAINT [PK__filtron_logistic__4C564A9F] PRIMARY KEY CLUSTERED 
(
	[logistics_info_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_makes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_makes](
	[make_id] [int] IDENTITY(1,1) NOT NULL,
	[make_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_m__make___0F624AF8]  DEFAULT (getdate()),
	[make_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_m__make___10566F31]  DEFAULT (getdate()),
	[make_name] [nvarchar](100) NOT NULL,
	[make_description] [nvarchar](255) NULL,
	[vehicle_id] [int] NOT NULL,
 CONSTRAINT [PK__filtron_makes__0E6E26BF] PRIMARY KEY CLUSTERED 
(
	[make_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_models]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_models](
	[model_id] [int] IDENTITY(1,1) NOT NULL,
	[model_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_m__model__151B244E]  DEFAULT (getdate()),
	[model_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_m__model__160F4887]  DEFAULT (getdate()),
	[model_name] [nvarchar](100) NOT NULL,
	[model_description] [nvarchar](255) NULL,
	[model_year_from] [int] NULL,
	[model_year_to] [int] NULL,
	[make_id] [int] NOT NULL,
 CONSTRAINT [PK__filtron_models__14270015] PRIMARY KEY CLUSTERED 
(
	[model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_special_filter_groups]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_special_filter_groups](
	[group_id] [int] IDENTITY(1,1) NOT NULL,
	[group_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_s__group__1EF99443]  DEFAULT (getdate()),
	[group_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_s__group__1FEDB87C]  DEFAULT (getdate()),
	[group_name] [nvarchar](100) NOT NULL,
	[group_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__filtron_special___1E05700A] PRIMARY KEY CLUSTERED 
(
	[group_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_special_filters]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_special_filters](
	[special_filter_id] [int] IDENTITY(1,1) NOT NULL,
	[special_filter_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_s__speci__2C538F61]  DEFAULT (getdate()),
	[special_filter_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_s__speci__2D47B39A]  DEFAULT (getdate()),
	[group_id] [int] NOT NULL,
	[filter_id] [int] NOT NULL,
	[special_filter_installation] [nvarchar](500) NULL,
 CONSTRAINT [PK__filtron_special___2B5F6B28] PRIMARY KEY CLUSTERED 
(
	[special_filter_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[filtron_vehicles]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[filtron_vehicles](
	[vehicle_id] [int] IDENTITY(1,1) NOT NULL,
	[vehicle_created] [datetime] NOT NULL CONSTRAINT [DF__filtron_v__vehic__0A9D95DB]  DEFAULT (getdate()),
	[vehicle_modified] [datetime] NOT NULL CONSTRAINT [DF__filtron_v__vehic__0B91BA14]  DEFAULT (getdate()),
	[vehicle_name] [nvarchar](100) NOT NULL,
	[vehicle_description] [nvarchar](255) NULL,
 CONSTRAINT [PK__filtron_vehicles__09A971A2] PRIMARY KEY CLUSTERED 
(
	[vehicle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[galleries]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[galleries](
	[gallery_id] [int] IDENTITY(1,1) NOT NULL,
	[gallery_created] [datetime] NOT NULL CONSTRAINT [DF__galleries__galle__2E1BDC42]  DEFAULT (getdate()),
	[gallery_modified] [datetime] NOT NULL CONSTRAINT [DF__galleries__galle__2F10007B]  DEFAULT (getdate()),
	[gallery_name] [nvarchar](255) NOT NULL,
	[gallery_alias] [nvarchar](255) NULL,
	[gallery_ordering] [int] NOT NULL CONSTRAINT [DF__galleries__galle__300424B4]  DEFAULT ((0)),
	[gallery_published] [bit] NOT NULL CONSTRAINT [DF__galleries__galle__30F848ED]  DEFAULT ((1)),
	[gallery_created_by_id] [int] NULL,
	[gallery_modified_by_id] [int] NULL,
	[module_id] [int] NULL,
	[language_id] [int] NULL,
	[template_id] [int] NULL,
 CONSTRAINT [PK__galleries__2D27B809] PRIMARY KEY CLUSTERED 
(
	[gallery_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[gallery_images]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[gallery_images](
	[gallery_image_id] [int] IDENTITY(1,1) NOT NULL,
	[gallery_image_created] [datetime] NOT NULL CONSTRAINT [DF__gallery_i__galle__46E78A0C]  DEFAULT (getdate()),
	[gallery_image_modified] [datetime] NOT NULL CONSTRAINT [DF__gallery_i__galle__47DBAE45]  DEFAULT (getdate()),
	[gallery_image_link] [nvarchar](255) NOT NULL,
	[gallery_image_info] [nvarchar](255) NOT NULL,
	[gallery_image_ordering] [int] NOT NULL CONSTRAINT [DF__gallery_i__galle__48CFD27E]  DEFAULT ((0)),
	[gallery_image_published] [bit] NULL CONSTRAINT [DF__gallery_i__galle__49C3F6B7]  DEFAULT ((1)),
	[gallery_image_created_by_id] [int] NULL,
	[gallery_image_modified_by_id] [int] NULL,
	[gallery_id] [int] NULL,
	[language_id] [int] NULL,
	[page_id] [int] NULL,
 CONSTRAINT [PK__gallery_images__45F365D3] PRIMARY KEY CLUSTERED 
(
	[gallery_image_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_comments]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_comments](
	[comment_id] [int] IDENTITY(1,1) NOT NULL,
	[comment_created] [datetime] NOT NULL CONSTRAINT [DF__import_fi__comme__3E082B48]  DEFAULT (getdate()),
	[comment_modified] [datetime] NOT NULL CONSTRAINT [DF__import_fi__comme__3EFC4F81]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[wix_number_hd] [nvarchar](80) NOT NULL,
	[comment] [nvarchar](800) NULL,
 CONSTRAINT [PK__import_filtron_c__3B2BBE9D] PRIMARY KEY CLUSTERED 
(
	[comment_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_ext_dim_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_ext_dim_bac](
	[dimid] [int] NOT NULL,
	[dictid] [int] NOT NULL,
	[dim_no] [int] NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_ext_dim_dict]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_ext_dim_dict](
	[ext_dim_dict_id] [int] IDENTITY(1,1) NOT NULL,
	[ext_dim_dict_created] [datetime] NOT NULL,
	[ext_dim_dict_modified] [datetime] NOT NULL,
	[dict_id] [int] NULL,
	[dict_pl] [nvarchar](100) NULL,
	[dict_en] [nvarchar](100) NULL,
	[dict_cz] [nvarchar](100) NULL,
	[dict_kind] [int] NULL,
	[dict_figure] [int] NULL,
	[dict_type] [nvarchar](100) NULL,
	[dim_a_available] [bit] NULL,
	[dim_b_available] [bit] NULL,
	[dim_c_available] [bit] NULL,
	[dim_d_available] [bit] NULL,
	[dim_e_available] [bit] NULL,
	[dim_f_available] [bit] NULL,
	[dim_g_available] [bit] NULL,
	[dim_h_available] [bit] NULL,
 CONSTRAINT [PK__import_filtron_e__379037E3] PRIMARY KEY CLUSTERED 
(
	[ext_dim_dict_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_ext_grupy_filtrow_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[import_filtron_ext_grupy_filtrow_bac](
	[gfiltr_id] [int] NOT NULL,
	[gfiltr_skrot] [varchar](50) NOT NULL,
	[gfiltr_nazwa_pl] [varchar](255) NULL,
	[gfiltr_nazwa_cz] [varchar](255) NULL,
	[gfiltr_nazwa_de] [varchar](255) NULL,
	[gfiltr_nazwa_en] [varchar](255) NULL,
	[gfiltr_nazwa_es] [varchar](255) NULL,
	[gfiltr_nazwa_hu] [varchar](255) NULL,
	[gfiltr_nazwa_ru] [varchar](255) NULL,
	[gfiltr_nazwa_ua] [varchar](255) NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[import_filtron_ext_spec_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[import_filtron_ext_spec_bac](
	[specid] [int] NOT NULL,
	[spec_filter_id] [int] NOT NULL,
	[spec_filter] [varchar](255) NOT NULL,
	[gfiltrid] [int] NOT NULL,
	[spec_application_pl] [nvarchar](max) NULL,
	[spec_typinstall_pl] [varchar](255) NULL,
	[spec_application_cz] [nvarchar](max) NULL,
	[spec_typinstall_cz] [varchar](255) NULL,
	[spec_application_de] [nvarchar](max) NULL,
	[spec_typinstall_de] [varchar](255) NULL,
	[spec_application_en] [nvarchar](max) NULL,
	[spec_typinstall_en] [varchar](255) NULL,
	[spec_application_es] [nvarchar](max) NULL,
	[spec_typinstall_es] [varchar](255) NULL,
	[spec_application_hu] [nvarchar](max) NULL,
	[spec_typinstall_hu] [varchar](255) NULL,
	[spec_application_ru] [nvarchar](max) NULL,
	[spec_typinstall_ru] [varchar](255) NULL,
	[spec_application_ua] [nvarchar](max) NULL,
	[spec_typinstall_ua] [varchar](255) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[import_filtron_filtry_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_filtry_bac](
	[IDfiltr] [int] NULL,
	[Nazwa] [nvarchar](max) NULL,
	[Rodzaj] [nvarchar](max) NULL,
	[typ] [nvarchar](max) NULL,
	[zastosowania] [nvarchar](max) NULL,
	[OD] [nvarchar](max) NULL,
	[ID] [nvarchar](max) NULL,
	[HGT] [nvarchar](max) NULL,
	[By_pass_Valve] [nvarchar](max) NULL,
	[Anti_drain_Valve] [nvarchar](max) NULL,
	[Anti_syphon_Valve] [nvarchar](max) NULL,
	[Status] [nvarchar](max) NULL,
	[DimC] [nvarchar](max) NULL,
	[DimD] [nvarchar](max) NULL,
	[DimE] [nvarchar](max) NULL,
	[DimF] [nvarchar](max) NULL,
	[DimG] [nvarchar](max) NULL,
	[BarCodeNumber] [nvarchar](max) NULL,
	[PDF] [nvarchar](max) NULL,
	[wix_numer] [nvarchar](25) NULL,
	[wix_numer_hd] [nvarchar](25) NULL,
	[dim2A] [nvarchar](25) NULL,
	[dim2B] [nvarchar](25) NULL,
	[dim2C] [nvarchar](25) NULL,
	[dim2D] [nvarchar](25) NULL,
	[dim2E] [nvarchar](25) NULL,
	[dim2F] [nvarchar](25) NULL,
	[dim2G] [nvarchar](25) NULL,
	[dim2H] [nvarchar](25) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_filtry_bac_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_filtry_bac_old](
	[IDfiltr] [int] NULL,
	[Nazwa] [nvarchar](max) NULL,
	[Rodzaj] [nvarchar](max) NULL,
	[typ] [nvarchar](max) NULL,
	[zastosowania] [nvarchar](max) NULL,
	[OD] [nvarchar](max) NULL,
	[ID] [nvarchar](max) NULL,
	[HGT] [nvarchar](max) NULL,
	[By_pass_Valve] [nvarchar](max) NULL,
	[Anti_drain_Valve] [nvarchar](max) NULL,
	[Anti_syphon_Valve] [nvarchar](max) NULL,
	[Status] [nvarchar](max) NULL,
	[DimC] [nvarchar](max) NULL,
	[DimD] [nvarchar](max) NULL,
	[DimE] [nvarchar](max) NULL,
	[DimF] [nvarchar](max) NULL,
	[DimG] [nvarchar](max) NULL,
	[BarCodeNumber] [nvarchar](max) NULL,
	[PDF] [nvarchar](max) NULL,
	[wix_numer] [nvarchar](25) NULL,
	[wix_numer_hd] [nvarchar](25) NULL,
	[dim2A] [nvarchar](25) NULL,
	[dim2B] [nvarchar](25) NULL,
	[dim2C] [nvarchar](25) NULL,
	[dim2D] [nvarchar](25) NULL,
	[dim2E] [nvarchar](25) NULL,
	[dim2F] [nvarchar](25) NULL,
	[dim2G] [nvarchar](25) NULL,
	[dim2H] [nvarchar](25) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_firmy_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_firmy_bac](
	[IDFirma] [int] NULL,
	[Firma] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_firmy_bac_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_firmy_bac_old](
	[IDFirma] [int] NULL,
	[Firma] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_katalog_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_katalog_bac](
	[Identyfikator] [int] NULL,
	[IDtyp] [int] NULL,
	[IDmarka] [int] NULL,
	[IDmodel] [int] NULL,
	[SILNIK] [text] NULL,
	[OPCJA] [nvarchar](max) NULL,
	[POJ_SILNIKA] [nvarchar](max) NULL,
	[TYP_SILNIKA] [nvarchar](max) NULL,
	[MOC] [nvarchar](max) NULL,
	[LATA] [nvarchar](max) NULL,
	[KOM1] [nvarchar](max) NULL,
	[IDfpow] [int] NULL,
	[KOM2] [nvarchar](max) NULL,
	[IDfolej] [int] NULL,
	[KOM3] [nvarchar](max) NULL,
	[IDfpaliw] [int] NULL,
	[KOM4] [nvarchar](max) NULL,
	[IDfinne] [int] NULL,
	[KOM5] [nvarchar](max) NULL,
	[FinneTYP] [nvarchar](max) NULL,
	[DataOrder] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_katalog_bac_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_katalog_bac_old](
	[Identyfikator] [int] NULL,
	[IDtyp] [int] NULL,
	[IDmarka] [int] NULL,
	[IDmodel] [int] NULL,
	[SILNIK] [text] NULL,
	[OPCJA] [nvarchar](max) NULL,
	[POJ_SILNIKA] [nvarchar](max) NULL,
	[TYP_SILNIKA] [nvarchar](max) NULL,
	[MOC] [nvarchar](max) NULL,
	[LATA] [nvarchar](max) NULL,
	[KOM1] [nvarchar](max) NULL,
	[IDfpow] [int] NULL,
	[KOM2] [nvarchar](max) NULL,
	[IDfolej] [int] NULL,
	[KOM3] [nvarchar](max) NULL,
	[IDfpaliw] [int] NULL,
	[KOM4] [nvarchar](max) NULL,
	[IDfinne] [int] NULL,
	[KOM5] [nvarchar](max) NULL,
	[FinneTYP] [nvarchar](max) NULL,
	[DataOrder] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_logistics_info]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_logistics_info](
	[import_logistics_info_id] [int] IDENTITY(1,1) NOT NULL,
	[logistics_info_created] [datetime] NOT NULL CONSTRAINT [DF__import_fi__logis__47919582]  DEFAULT (getdate()),
	[logistics_info_modified] [datetime] NOT NULL CONSTRAINT [DF__import_fi__logis__4885B9BB]  DEFAULT (getdate()),
	[filter_number] [nvarchar](255) NOT NULL,
	[hd] [nvarchar](80) NULL,
	[min_ilosc_zam] [int] NULL,
	[ilosc_zg] [int] NULL,
	[ilosc_pal] [int] NULL,
	[kart_w] [int] NULL,
	[kart_h] [int] NULL,
	[kart_l] [int] NULL,
	[waga] [nvarchar](80) NULL,
	[kod_ean] [nvarchar](80) NULL,
 CONSTRAINT [PK__import_filtron_l__469D7149] PRIMARY KEY CLUSTERED 
(
	[import_logistics_info_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_marka_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_marka_bac](
	[IDmarka] [int] NULL,
	[Marka] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_marka_bac_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_marka_bac_old](
	[IDmarka] [int] NULL,
	[Marka] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_model_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_model_bac](
	[IDmodel] [int] NULL,
	[Model] [nvarchar](max) NULL,
	[MODEL_SORT] [nvarchar](max) NULL,
	[MODEL_SORT_2] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_model_bac_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_model_bac_old](
	[IDmodel] [int] NULL,
	[Model] [nvarchar](max) NULL,
	[MODEL_SORT] [nvarchar](max) NULL,
	[MODEL_SORT_2] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_oe_producers]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_oe_producers](
	[import_producer_id] [int] IDENTITY(1,1) NOT NULL,
	[producer_created] [datetime] NOT NULL CONSTRAINT [DF__import_fi__produ__41D8BC2C]  DEFAULT (getdate()),
	[producer_modified] [datetime] NOT NULL CONSTRAINT [DF__import_fi__produ__42CCE065]  DEFAULT (getdate()),
	[producer_id] [int] NOT NULL,
	[producer_name] [nvarchar](255) NOT NULL,
	[producer_oe] [nvarchar](20) NULL,
 CONSTRAINT [PK__import_filtron_o__40E497F3] PRIMARY KEY CLUSTERED 
(
	[import_producer_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_typpojazdu_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_typpojazdu_bac](
	[IDtyp] [int] NULL,
	[TypPojazdu] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_zamienniki_bac]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_zamienniki_bac](
	[IDzamienniki] [int] NULL,
	[IDfiltr] [int] NULL,
	[IDfirma] [int] NULL,
	[Obcy] [nvarchar](max) NULL,
	[Obcy_AN] [nvarchar](max) NULL,
	[status_wix] [int] NULL CONSTRAINT [DF__import_fi__statu__7BB05806]  DEFAULT ((0))
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_filtron_zamienniki_bac_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_filtron_zamienniki_bac_old](
	[IDzamienniki] [int] NULL,
	[IDfiltr] [int] NULL,
	[IDfirma] [int] NULL,
	[Obcy] [nvarchar](max) NULL,
	[Obcy_AN] [nvarchar](max) NULL,
	[status_wix] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_atv]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_atv](
	[atv_id] [int] IDENTITY(1,1) NOT NULL,
	[atv_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__atv_c__0DCF0841]  DEFAULT (getdate()),
	[atv_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__atv_m__0EC32C7A]  DEFAULT (getdate()),
	[atv_section] [int] NOT NULL,
	[atv_make] [nvarchar](100) NOT NULL,
	[atv_year] [int] NULL,
	[atv_model] [nvarchar](100) NOT NULL,
	[atv_submodel] [nvarchar](100) NULL,
	[atv_engine] [nvarchar](100) NULL,
	[atv_engine_footnote] [nvarchar](255) NULL,
	[atv_exception1] [nvarchar](100) NULL,
	[atv_exception2] [nvarchar](100) NULL,
	[atv_exception3] [nvarchar](100) NULL,
	[atv_vin_code] [nvarchar](100) NULL,
	[atv_part_type] [nvarchar](10) NULL,
	[atv_sort_order] [int] NULL,
	[atv_filter_number] [nvarchar](100) NOT NULL,
	[atv_footnote1] [nvarchar](100) NULL,
	[atv_footnote2] [nvarchar](100) NULL,
	[atv_footnote3] [nvarchar](100) NULL,
	[atv_comment1] [nvarchar](100) NULL,
	[atv_comment2] [nvarchar](100) NULL,
	[atv_filter_locator] [nvarchar](50) NULL,
	[atv_in_catalog] [nvarchar](1) NULL,
 CONSTRAINT [PK__import_wix_atv__0CDAE408] PRIMARY KEY CLUSTERED 
(
	[atv_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_atv_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_atv_old](
	[atv_id] [int] IDENTITY(1,1) NOT NULL,
	[atv_created] [datetime] NOT NULL,
	[atv_modified] [datetime] NOT NULL,
	[atv_section] [int] NOT NULL,
	[atv_make] [nvarchar](100) NOT NULL,
	[atv_year] [int] NULL,
	[atv_model] [nvarchar](100) NOT NULL,
	[atv_submodel] [nvarchar](100) NULL,
	[atv_engine] [nvarchar](100) NULL,
	[atv_engine_footnote] [nvarchar](255) NULL,
	[atv_exception1] [nvarchar](100) NULL,
	[atv_exception2] [nvarchar](100) NULL,
	[atv_exception3] [nvarchar](100) NULL,
	[atv_vin_code] [nvarchar](100) NULL,
	[atv_part_type] [nvarchar](10) NULL,
	[atv_sort_order] [int] NULL,
	[atv_filter_number] [nvarchar](100) NOT NULL,
	[atv_footnote1] [nvarchar](100) NULL,
	[atv_footnote2] [nvarchar](100) NULL,
	[atv_footnote3] [nvarchar](100) NULL,
	[atv_comment1] [nvarchar](100) NULL,
	[atv_comment2] [nvarchar](100) NULL,
	[atv_filter_locator] [nvarchar](50) NULL,
	[atv_in_catalog] [nvarchar](1) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_bus_track]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_bus_track](
	[bus_track_id] [int] IDENTITY(1,1) NOT NULL,
	[bus_track_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__bus_t__689D8392]  DEFAULT (getdate()),
	[bus_track_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__bus_t__6991A7CB]  DEFAULT (getdate()),
	[bus_track_section] [int] NOT NULL,
	[bus_track_make] [nvarchar](100) NOT NULL,
	[bus_track_year] [int] NULL,
	[bus_track_model] [nvarchar](100) NOT NULL,
	[bus_track_submodel] [nvarchar](100) NULL,
	[bus_track_engine] [nvarchar](100) NULL,
	[bus_track_engine_footnote] [nvarchar](255) NULL,
	[bus_track_exception1] [nvarchar](100) NULL,
	[bus_track_exception2] [nvarchar](100) NULL,
	[bus_track_exception3] [nvarchar](100) NULL,
	[bus_track_vin_code] [nvarchar](100) NULL,
	[bus_track_part_type] [nvarchar](10) NULL,
	[bus_track_sort_order] [int] NULL,
	[bus_track_filter_number] [nvarchar](100) NOT NULL,
	[bus_track_footnote1] [nvarchar](100) NULL,
	[bus_track_footnote2] [nvarchar](100) NULL,
	[bus_track_footnote3] [nvarchar](100) NULL,
	[bus_track_comment1] [nvarchar](100) NULL,
	[bus_track_comment2] [nvarchar](100) NULL,
	[bus_track_filter_locator] [nvarchar](50) NULL,
	[bus_track_in_catalog] [nvarchar](1) NULL,
 CONSTRAINT [PK__import_wix_bus_t__67A95F59] PRIMARY KEY CLUSTERED 
(
	[bus_track_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_bus_track_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_bus_track_old](
	[bus_track_id] [int] IDENTITY(1,1) NOT NULL,
	[bus_track_created] [datetime] NOT NULL,
	[bus_track_modified] [datetime] NOT NULL,
	[bus_track_section] [int] NOT NULL,
	[bus_track_make] [nvarchar](100) NOT NULL,
	[bus_track_year] [int] NULL,
	[bus_track_model] [nvarchar](100) NOT NULL,
	[bus_track_submodel] [nvarchar](100) NULL,
	[bus_track_engine] [nvarchar](100) NULL,
	[bus_track_engine_footnote] [nvarchar](255) NULL,
	[bus_track_exception1] [nvarchar](100) NULL,
	[bus_track_exception2] [nvarchar](100) NULL,
	[bus_track_exception3] [nvarchar](100) NULL,
	[bus_track_vin_code] [nvarchar](100) NULL,
	[bus_track_part_type] [nvarchar](10) NULL,
	[bus_track_sort_order] [int] NULL,
	[bus_track_filter_number] [nvarchar](100) NOT NULL,
	[bus_track_footnote1] [nvarchar](100) NULL,
	[bus_track_footnote2] [nvarchar](100) NULL,
	[bus_track_footnote3] [nvarchar](100) NULL,
	[bus_track_comment1] [nvarchar](100) NULL,
	[bus_track_comment2] [nvarchar](100) NULL,
	[bus_track_filter_locator] [nvarchar](50) NULL,
	[bus_track_in_catalog] [nvarchar](1) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_filters]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_filters](
	[filter_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__filte__70FDBF69]  DEFAULT (getdate()),
	[filter_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__filte__71F1E3A2]  DEFAULT (getdate()),
	[filter_number] [nvarchar](100) NOT NULL,
	[filter_type] [nvarchar](10) NULL,
	[filter_service] [nvarchar](10) NULL,
	[filter_media] [nvarchar](10) NULL,
	[filter_height] [decimal](18, 4) NULL,
	[filter_width] [decimal](18, 4) NULL,
	[filter_length] [decimal](18, 4) NULL,
	[filter_outside_dia_top] [decimal](18, 4) NULL,
	[filter_outside_dia_bottom] [decimal](18, 4) NULL,
	[filter_inside_dia_top] [decimal](18, 4) NULL,
	[filter_inside_dia_bottom] [decimal](18, 4) NULL,
	[filter_cubic_feet_per_minute] [int] NULL,
	[filter_micron] [int] NULL,
	[filter_thread_size] [nvarchar](80) NULL,
	[filter_ends] [nvarchar](1) NULL,
	[filter_fins] [nvarchar](1) NULL,
	[filter_oval_shaped] [nvarchar](1) NULL,
	[filter_shape_desc] [nvarchar](80) NULL,
	[filter_inlet] [nvarchar](80) NULL,
	[filter_outlet] [nvarchar](80) NULL,
	[filter_vapor] [nvarchar](80) NULL,
	[filter_threads] [nvarchar](80) NULL,
	[filter_bpvs] [nvarchar](80) NULL,
	[filter_adbv] [nvarchar](1) NULL,
	[filter_pressure_release] [nvarchar](1) NULL,
	[filter_stand_pipe] [nvarchar](1) NULL,
	[filter_anti_siphon_valve] [nvarchar](1) NULL,
	[filter_beta_ratio] [nvarchar](80) NULL,
	[filter_tube_layout] [nvarchar](80) NULL,
	[filter_drain] [nvarchar](1) NULL,
	[filter_burst_pressure] [int] NULL,
	[filter_flow_rate] [nvarchar](80) NULL,
	[filter_illustration] [nvarchar](80) NULL,
	[filter_style] [nvarchar](10) NULL,
	[filter_principle_applications] [nvarchar](max) NULL,
	[filter_gasket_sort_order] [int] NULL,
	[filter_gasket_desc] [nvarchar](80) NULL,
	[filter_gasket_footnote] [nvarchar](80) NULL,
	[filter_gasket_number] [nvarchar](100) NULL,
	[filter_gasket_od] [decimal](18, 4) NULL,
	[filter_gasket_id] [decimal](18, 4) NULL,
	[filter_gasket_thickness] [decimal](18, 4) NULL,
 CONSTRAINT [PK__import_wix_filte__70099B30] PRIMARY KEY CLUSTERED 
(
	[filter_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_filters_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_filters_old](
	[filter_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_created] [datetime] NOT NULL,
	[filter_modified] [datetime] NOT NULL,
	[filter_number] [nvarchar](100) NOT NULL,
	[filter_type] [nvarchar](10) NULL,
	[filter_service] [nvarchar](10) NULL,
	[filter_media] [nvarchar](10) NULL,
	[filter_height] [decimal](18, 4) NULL,
	[filter_width] [decimal](18, 4) NULL,
	[filter_length] [decimal](18, 4) NULL,
	[filter_outside_dia_top] [decimal](18, 4) NULL,
	[filter_outside_dia_bottom] [decimal](18, 4) NULL,
	[filter_inside_dia_top] [decimal](18, 4) NULL,
	[filter_inside_dia_bottom] [decimal](18, 4) NULL,
	[filter_cubic_feet_per_minute] [int] NULL,
	[filter_micron] [int] NULL,
	[filter_thread_size] [nvarchar](80) NULL,
	[filter_ends] [nvarchar](1) NULL,
	[filter_fins] [nvarchar](1) NULL,
	[filter_oval_shaped] [nvarchar](1) NULL,
	[filter_shape_desc] [nvarchar](80) NULL,
	[filter_inlet] [nvarchar](80) NULL,
	[filter_outlet] [nvarchar](80) NULL,
	[filter_vapor] [nvarchar](80) NULL,
	[filter_threads] [nvarchar](80) NULL,
	[filter_bpvs] [nvarchar](80) NULL,
	[filter_adbv] [nvarchar](1) NULL,
	[filter_pressure_release] [nvarchar](1) NULL,
	[filter_stand_pipe] [nvarchar](1) NULL,
	[filter_anti_siphon_valve] [nvarchar](1) NULL,
	[filter_beta_ratio] [nvarchar](80) NULL,
	[filter_tube_layout] [nvarchar](80) NULL,
	[filter_drain] [nvarchar](1) NULL,
	[filter_burst_pressure] [int] NULL,
	[filter_flow_rate] [nvarchar](80) NULL,
	[filter_illustration] [nvarchar](80) NULL,
	[filter_style] [nvarchar](10) NULL,
	[filter_principle_applications] [nvarchar](max) NULL,
	[filter_gasket_sort_order] [int] NULL,
	[filter_gasket_desc] [nvarchar](80) NULL,
	[filter_gasket_footnote] [nvarchar](80) NULL,
	[filter_gasket_number] [nvarchar](100) NULL,
	[filter_gasket_od] [decimal](18, 4) NULL,
	[filter_gasket_id] [decimal](18, 4) NULL,
	[filter_gasket_thickness] [decimal](18, 4) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_interchanges]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_interchanges](
	[interchange_id] [int] IDENTITY(1,1) NOT NULL,
	[interchange_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__inter__4FD1D5C8]  DEFAULT (getdate()),
	[interchange_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__inter__50C5FA01]  DEFAULT (getdate()),
	[interchange_manufacturer_name] [nvarchar](500) NOT NULL,
	[interchange_manufacturer_description] [nvarchar](500) NULL,
	[foreign_filter_number] [nvarchar](500) NOT NULL,
	[child_foot_note] [int] NULL,
	[sort_order] [int] NULL,
	[filter_number] [nvarchar](80) NULL,
	[filter_prefix] [nvarchar](500) NULL,
	[filter_suffix] [nvarchar](500) NULL,
	[parent_foot_note] [nvarchar](500) NULL,
 CONSTRAINT [PK__import_wix_inter__4EDDB18F] PRIMARY KEY CLUSTERED 
(
	[interchange_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_interchanges_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_interchanges_old](
	[interchange_id] [int] IDENTITY(1,1) NOT NULL,
	[interchange_created] [datetime] NOT NULL,
	[interchange_modified] [datetime] NOT NULL,
	[interchange_manufacturer_name] [nvarchar](500) NOT NULL,
	[interchange_manufacturer_description] [nvarchar](500) NULL,
	[foreign_filter_number] [nvarchar](500) NOT NULL,
	[child_foot_note] [int] NULL,
	[sort_order] [int] NULL,
	[filter_number] [nvarchar](80) NULL,
	[filter_prefix] [nvarchar](500) NULL,
	[filter_suffix] [nvarchar](500) NULL,
	[parent_foot_note] [nvarchar](500) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_light_truck]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_light_truck](
	[light_truck_id] [int] IDENTITY(1,1) NOT NULL,
	[light_truck_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__light__1446FBA6]  DEFAULT (getdate()),
	[light_truck_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__light__153B1FDF]  DEFAULT (getdate()),
	[light_truck_section] [int] NOT NULL,
	[light_truck_make] [nvarchar](100) NOT NULL,
	[light_truck_year] [int] NULL,
	[light_truck_model] [nvarchar](100) NOT NULL,
	[light_truck_submodel] [nvarchar](100) NULL,
	[light_truck_engine] [nvarchar](100) NULL,
	[light_truck_engine_footnote] [nvarchar](255) NULL,
	[light_truck_exception1] [nvarchar](100) NULL,
	[light_truck_exception2] [nvarchar](100) NULL,
	[light_truck_exception3] [nvarchar](100) NULL,
	[light_truck_vin_code] [nvarchar](100) NULL,
	[light_truck_part_type] [nvarchar](10) NULL,
	[light_truck_sort_order] [int] NULL,
	[light_truck_filter_number] [nvarchar](100) NOT NULL,
	[light_truck_footnote1] [nvarchar](100) NULL,
	[light_truck_footnote2] [nvarchar](100) NULL,
	[light_truck_footnote3] [nvarchar](100) NULL,
	[light_truck_comment1] [nvarchar](100) NULL,
	[light_truck_comment2] [nvarchar](100) NULL,
	[light_truck_filter_locator] [nvarchar](50) NULL,
	[light_truck_in_catalog] [nvarchar](1) NULL,
 CONSTRAINT [PK__import_wix_light__1352D76D] PRIMARY KEY CLUSTERED 
(
	[light_truck_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_light_truck_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_light_truck_old](
	[light_truck_id] [int] IDENTITY(1,1) NOT NULL,
	[light_truck_created] [datetime] NOT NULL,
	[light_truck_modified] [datetime] NOT NULL,
	[light_truck_section] [int] NOT NULL,
	[light_truck_make] [nvarchar](100) NOT NULL,
	[light_truck_year] [int] NULL,
	[light_truck_model] [nvarchar](100) NOT NULL,
	[light_truck_submodel] [nvarchar](100) NULL,
	[light_truck_engine] [nvarchar](100) NULL,
	[light_truck_engine_footnote] [nvarchar](255) NULL,
	[light_truck_exception1] [nvarchar](100) NULL,
	[light_truck_exception2] [nvarchar](100) NULL,
	[light_truck_exception3] [nvarchar](100) NULL,
	[light_truck_vin_code] [nvarchar](100) NULL,
	[light_truck_part_type] [nvarchar](10) NULL,
	[light_truck_sort_order] [int] NULL,
	[light_truck_filter_number] [nvarchar](100) NOT NULL,
	[light_truck_footnote1] [nvarchar](100) NULL,
	[light_truck_footnote2] [nvarchar](100) NULL,
	[light_truck_footnote3] [nvarchar](100) NULL,
	[light_truck_comment1] [nvarchar](100) NULL,
	[light_truck_comment2] [nvarchar](100) NULL,
	[light_truck_filter_locator] [nvarchar](50) NULL,
	[light_truck_in_catalog] [nvarchar](1) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_motorcycle]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_motorcycle](
	[motorcycle_id] [int] IDENTITY(1,1) NOT NULL,
	[motorcycle_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__motor__1293BD5E]  DEFAULT (getdate()),
	[motorcycle_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__motor__1387E197]  DEFAULT (getdate()),
	[motorcycle_section] [int] NOT NULL,
	[motorcycle_make] [nvarchar](100) NOT NULL,
	[motorcycle_year] [int] NULL,
	[motorcycle_model] [nvarchar](100) NOT NULL,
	[motorcycle_submodel] [nvarchar](100) NULL,
	[motorcycle_engine] [nvarchar](100) NULL,
	[motorcycle_engine_footnote] [nvarchar](255) NULL,
	[motorcycle_exception1] [nvarchar](100) NULL,
	[motorcycle_exception2] [nvarchar](100) NULL,
	[motorcycle_exception3] [nvarchar](100) NULL,
	[motorcycle_vin_code] [nvarchar](100) NULL,
	[motorcycle_part_type] [nvarchar](10) NULL,
	[motorcycle_sort_order] [int] NULL,
	[motorcycle_filter_number] [nvarchar](100) NOT NULL,
	[motorcycle_footnote1] [nvarchar](100) NULL,
	[motorcycle_footnote2] [nvarchar](100) NULL,
	[motorcycle_footnote3] [nvarchar](100) NULL,
	[motorcycle_comment1] [nvarchar](100) NULL,
	[motorcycle_comment2] [nvarchar](100) NULL,
	[motorcycle_filter_locator] [nvarchar](50) NULL,
	[motorcycle_in_catalog] [nvarchar](1) NULL,
 CONSTRAINT [PK__import_wix_motor__119F9925] PRIMARY KEY CLUSTERED 
(
	[motorcycle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_motorcycle_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_motorcycle_old](
	[motorcycle_id] [int] IDENTITY(1,1) NOT NULL,
	[motorcycle_created] [datetime] NOT NULL,
	[motorcycle_modified] [datetime] NOT NULL,
	[motorcycle_section] [int] NOT NULL,
	[motorcycle_make] [nvarchar](100) NOT NULL,
	[motorcycle_year] [int] NULL,
	[motorcycle_model] [nvarchar](100) NOT NULL,
	[motorcycle_submodel] [nvarchar](100) NULL,
	[motorcycle_engine] [nvarchar](100) NULL,
	[motorcycle_engine_footnote] [nvarchar](255) NULL,
	[motorcycle_exception1] [nvarchar](100) NULL,
	[motorcycle_exception2] [nvarchar](100) NULL,
	[motorcycle_exception3] [nvarchar](100) NULL,
	[motorcycle_vin_code] [nvarchar](100) NULL,
	[motorcycle_part_type] [nvarchar](10) NULL,
	[motorcycle_sort_order] [int] NULL,
	[motorcycle_filter_number] [nvarchar](100) NOT NULL,
	[motorcycle_footnote1] [nvarchar](100) NULL,
	[motorcycle_footnote2] [nvarchar](100) NULL,
	[motorcycle_footnote3] [nvarchar](100) NULL,
	[motorcycle_comment1] [nvarchar](100) NULL,
	[motorcycle_comment2] [nvarchar](100) NULL,
	[motorcycle_filter_locator] [nvarchar](50) NULL,
	[motorcycle_in_catalog] [nvarchar](1) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_off_highway]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_off_highway](
	[off_highway_id] [int] IDENTITY(1,1) NOT NULL,
	[off_highway_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__off_h__6D6238AF]  DEFAULT (getdate()),
	[off_highway_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__off_h__6E565CE8]  DEFAULT (getdate()),
	[off_highway_section] [int] NOT NULL,
	[off_highway_make] [nvarchar](100) NOT NULL,
	[off_highway_year] [int] NULL,
	[off_highway_model] [nvarchar](100) NOT NULL,
	[off_highway_submodel] [nvarchar](100) NULL,
	[off_highway_engine] [nvarchar](100) NULL,
	[off_highway_engine_footnote] [nvarchar](255) NULL,
	[off_highway_exception1] [nvarchar](100) NULL,
	[off_highway_exception2] [nvarchar](100) NULL,
	[off_highway_exception3] [nvarchar](100) NULL,
	[off_highway_vin_code] [nvarchar](100) NULL,
	[off_highway_part_type] [nvarchar](10) NULL,
	[off_highway_sort_order] [int] NULL,
	[off_highway_filter_number] [nvarchar](100) NOT NULL,
	[off_highway_footnote1] [nvarchar](100) NULL,
	[off_highway_footnote2] [nvarchar](100) NULL,
	[off_highway_footnote3] [nvarchar](100) NULL,
	[off_highway_comment1] [nvarchar](100) NULL,
	[off_highway_comment2] [nvarchar](100) NULL,
	[off_highway_filter_locator] [nvarchar](50) NULL,
	[off_highway_in_catalog] [nvarchar](1) NULL,
 CONSTRAINT [PK__import_wix_off_h__6C6E1476] PRIMARY KEY CLUSTERED 
(
	[off_highway_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_off_highway_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_off_highway_old](
	[off_highway_id] [int] IDENTITY(1,1) NOT NULL,
	[off_highway_created] [datetime] NOT NULL,
	[off_highway_modified] [datetime] NOT NULL,
	[off_highway_section] [int] NOT NULL,
	[off_highway_make] [nvarchar](100) NOT NULL,
	[off_highway_year] [int] NULL,
	[off_highway_model] [nvarchar](100) NOT NULL,
	[off_highway_submodel] [nvarchar](100) NULL,
	[off_highway_engine] [nvarchar](100) NULL,
	[off_highway_engine_footnote] [nvarchar](255) NULL,
	[off_highway_exception1] [nvarchar](100) NULL,
	[off_highway_exception2] [nvarchar](100) NULL,
	[off_highway_exception3] [nvarchar](100) NULL,
	[off_highway_vin_code] [nvarchar](100) NULL,
	[off_highway_part_type] [nvarchar](10) NULL,
	[off_highway_sort_order] [int] NULL,
	[off_highway_filter_number] [nvarchar](100) NOT NULL,
	[off_highway_footnote1] [nvarchar](100) NULL,
	[off_highway_footnote2] [nvarchar](100) NULL,
	[off_highway_footnote3] [nvarchar](100) NULL,
	[off_highway_comment1] [nvarchar](100) NULL,
	[off_highway_comment2] [nvarchar](100) NULL,
	[off_highway_filter_locator] [nvarchar](50) NULL,
	[off_highway_in_catalog] [nvarchar](1) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_passenger]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_passenger](
	[passenger_id] [int] IDENTITY(1,1) NOT NULL,
	[passenger_created] [datetime] NOT NULL CONSTRAINT [DF__import_wi__passe__36D11DD4]  DEFAULT (getdate()),
	[passenger_modified] [datetime] NOT NULL CONSTRAINT [DF__import_wi__passe__37C5420D]  DEFAULT (getdate()),
	[passenger_section] [int] NOT NULL,
	[passenger_make] [nvarchar](100) NOT NULL,
	[passenger_year] [int] NULL,
	[passenger_model] [nvarchar](100) NOT NULL,
	[passenger_submodel] [nvarchar](100) NULL,
	[passenger_engine] [nvarchar](100) NULL,
	[passenger_engine_footnote] [nvarchar](255) NULL,
	[passenger_exception1] [nvarchar](100) NULL,
	[passenger_exception2] [nvarchar](100) NULL,
	[passenger_exception3] [nvarchar](100) NULL,
	[passenger_vin_code] [nvarchar](100) NULL,
	[passenger_part_type] [nvarchar](10) NULL,
	[passenger_sort_order] [int] NULL,
	[passenger_filter_number] [nvarchar](100) NOT NULL,
	[passenger_footnote1] [nvarchar](100) NULL,
	[passenger_footnote2] [nvarchar](100) NULL,
	[passenger_footnote3] [nvarchar](100) NULL,
	[passenger_comment1] [nvarchar](100) NULL,
	[passenger_comment2] [nvarchar](100) NULL,
	[passenger_filter_locator] [nvarchar](50) NULL,
	[passenger_in_catalog] [nvarchar](1) NULL,
 CONSTRAINT [PK__import_wix_passe__35DCF99B] PRIMARY KEY CLUSTERED 
(
	[passenger_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[import_wix_passenger_old]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[import_wix_passenger_old](
	[passenger_id] [int] IDENTITY(1,1) NOT NULL,
	[passenger_created] [datetime] NOT NULL,
	[passenger_modified] [datetime] NOT NULL,
	[passenger_section] [int] NOT NULL,
	[passenger_make] [nvarchar](100) NOT NULL,
	[passenger_year] [int] NULL,
	[passenger_model] [nvarchar](100) NOT NULL,
	[passenger_submodel] [nvarchar](100) NULL,
	[passenger_engine] [nvarchar](100) NULL,
	[passenger_engine_footnote] [nvarchar](255) NULL,
	[passenger_exception1] [nvarchar](100) NULL,
	[passenger_exception2] [nvarchar](100) NULL,
	[passenger_exception3] [nvarchar](100) NULL,
	[passenger_vin_code] [nvarchar](100) NULL,
	[passenger_part_type] [nvarchar](10) NULL,
	[passenger_sort_order] [int] NULL,
	[passenger_filter_number] [nvarchar](100) NOT NULL,
	[passenger_footnote1] [nvarchar](100) NULL,
	[passenger_footnote2] [nvarchar](100) NULL,
	[passenger_footnote3] [nvarchar](100) NULL,
	[passenger_comment1] [nvarchar](100) NULL,
	[passenger_comment2] [nvarchar](100) NULL,
	[passenger_filter_locator] [nvarchar](50) NULL,
	[passenger_in_catalog] [nvarchar](1) NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[languages]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[languages](
	[language_id] [int] IDENTITY(1,1) NOT NULL,
	[language_created] [datetime] NOT NULL CONSTRAINT [DF__languages__langu__0519C6AF]  DEFAULT (getdate()),
	[language_modified] [datetime] NOT NULL CONSTRAINT [DF__languages__langu__060DEAE8]  DEFAULT (getdate()),
	[language_abbr] [nvarchar](20) NOT NULL,
	[language_name] [nvarchar](80) NOT NULL,
	[language_img] [nvarchar](100) NULL,
	[language_created_by_id] [int] NULL,
	[language_modified_by_id] [int] NULL,
	[language_is_default] [bit] NOT NULL CONSTRAINT [DF__languages__langu__07020F21]  DEFAULT ((0)),
	[language_active] [bit] NULL CONSTRAINT [DF__languages__langu__44EA3301]  DEFAULT ((0)),
 CONSTRAINT [PK__languages__0425A276] PRIMARY KEY CLUSTERED 
(
	[language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[last_searches]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[last_searches](
	[last_search_id] [int] IDENTITY(1,1) NOT NULL,
	[last_search_name] [nvarchar](255) NULL,
	[last_search_link] [nvarchar](255) NULL,
	[language_id] [int] NULL,
 CONSTRAINT [PK__last_searches] PRIMARY KEY CLUSTERED 
(
	[last_search_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[menu_item_types]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[menu_item_types](
	[type_id] [int] IDENTITY(1,1) NOT NULL,
	[type_created] [datetime] NOT NULL CONSTRAINT [DF__menu_item__type___6E01572D]  DEFAULT (getdate()),
	[type_modified] [datetime] NOT NULL CONSTRAINT [DF__menu_item__type___6EF57B66]  DEFAULT (getdate()),
	[type_abbr] [nvarchar](20) NOT NULL,
	[type_name] [nvarchar](80) NOT NULL,
	[type_img] [nvarchar](100) NULL,
	[type_description] [nvarchar](255) NULL,
	[type_hidden] [bit] NOT NULL CONSTRAINT [DF__menu_item__type___6FE99F9F]  DEFAULT ((0)),
 CONSTRAINT [PK__menu_item_types__6D0D32F4] PRIMARY KEY CLUSTERED 
(
	[type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[menu_items]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[menu_items](
	[item_id] [int] IDENTITY(1,1) NOT NULL,
	[item_created] [datetime] NOT NULL CONSTRAINT [DF__menu_item__item___7C4F7684]  DEFAULT (getdate()),
	[item_modified] [datetime] NOT NULL CONSTRAINT [DF__menu_item__item___7D439ABD]  DEFAULT (getdate()),
	[item_name] [nvarchar](80) NOT NULL,
	[item_alias] [nvarchar](190) NULL,
	[item_img] [nvarchar](100) NULL,
	[item_ordering] [int] NOT NULL CONSTRAINT [DF__menu_item__item___7E37BEF6]  DEFAULT ((0)),
	[item_published] [bit] NOT NULL CONSTRAINT [DF__menu_item__item___7F2BE32F]  DEFAULT ((1)),
	[item_link] [nvarchar](190) NOT NULL,
	[item_type_id] [int] NOT NULL,
	[parent_item_id] [int] NULL,
	[menu_id] [int] NULL,
	[item_editable] [bit] NOT NULL CONSTRAINT [DF__menu_item__item___00200768]  DEFAULT ((1)),
	[item_removable] [bit] NOT NULL CONSTRAINT [DF__menu_item__item___01142BA1]  DEFAULT ((1)),
	[item_created_by_id] [int] NULL,
	[item_modified_by_id] [int] NULL,
	[item_path] [nvarchar](max) NULL,
	[item_depth] [int] NOT NULL,
	[page_id] [int] NULL,
 CONSTRAINT [PK__menu_items__7B5B524B] PRIMARY KEY CLUSTERED 
(
	[item_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[menus]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[menus](
	[menu_id] [int] IDENTITY(1,1) NOT NULL,
	[menu_created] [datetime] NOT NULL CONSTRAINT [DF__menus__menu_crea__73BA3083]  DEFAULT (getdate()),
	[menu_modified] [datetime] NOT NULL CONSTRAINT [DF__menus__menu_modi__74AE54BC]  DEFAULT (getdate()),
	[menu_name] [nvarchar](50) NULL CONSTRAINT [DF__menus__menu_name__75A278F5]  DEFAULT (NULL),
	[menu_description] [nvarchar](255) NULL,
	[menu_hidden] [bit] NOT NULL CONSTRAINT [DF__menus__menu_hidd__76969D2E]  DEFAULT ((0)),
	[language_id] [int] NULL,
	[module_id] [int] NULL,
 CONSTRAINT [PK__menus__72C60C4A] PRIMARY KEY CLUSTERED 
(
	[menu_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[modules]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[modules](
	[module_id] [int] IDENTITY(1,1) NOT NULL,
	[module_created] [datetime] NOT NULL CONSTRAINT [DF__modules__module___145C0A3F]  DEFAULT (getdate()),
	[module_modified] [datetime] NOT NULL CONSTRAINT [DF__modules__module___15502E78]  DEFAULT (getdate()),
	[module_name] [nvarchar](80) NOT NULL,
	[module_description] [nvarchar](255) NULL,
	[module_link] [nvarchar](255) NOT NULL,
	[language_id] [int] NULL,
 CONSTRAINT [PK__modules__1367E606] PRIMARY KEY CLUSTERED 
(
	[module_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[modules_templates]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[modules_templates](
	[module_template_id] [int] IDENTITY(1,1) NOT NULL,
	[module_template_created] [datetime] NOT NULL CONSTRAINT [DF__modules_t__modul__276EDEB3]  DEFAULT (getdate()),
	[module_template_modified] [datetime] NOT NULL CONSTRAINT [DF__modules_t__modul__286302EC]  DEFAULT (getdate()),
	[module_id] [int] NULL,
	[template_id] [int] NULL,
 CONSTRAINT [PK__modules_template__267ABA7A] PRIMARY KEY CLUSTERED 
(
	[module_template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[page_types]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[page_types](
	[page_type_id] [int] IDENTITY(1,1) NOT NULL,
	[page_type_created] [datetime] NOT NULL CONSTRAINT [DF__page_type__page___1A14E395]  DEFAULT (getdate()),
	[page_type_modified] [datetime] NOT NULL CONSTRAINT [DF__page_type__page___1B0907CE]  DEFAULT (getdate()),
	[page_type_name] [nvarchar](80) NOT NULL,
	[page_type_description] [nvarchar](255) NULL,
	[page_type_editable] [bit] NOT NULL CONSTRAINT [DF__page_type__page___1BFD2C07]  DEFAULT ((1)),
	[page_type_abbr] [nvarchar](20) NULL,
	[page_type_link] [nvarchar](255) NULL,
	[language_id] [int] NULL,
 CONSTRAINT [PK__page_types__1920BF5C] PRIMARY KEY CLUSTERED 
(
	[page_type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[page_types_acceptable_templates]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[page_types_acceptable_templates](
	[page_type_template_id] [int] IDENTITY(1,1) NOT NULL,
	[page_type_template_created] [datetime] NOT NULL CONSTRAINT [DF__page_type__page___20C1E124]  DEFAULT (getdate()),
	[page_type_template_modified] [datetime] NOT NULL CONSTRAINT [DF__page_type__page___21B6055D]  DEFAULT (getdate()),
	[page_type_id] [int] NULL,
	[template_id] [int] NULL,
 CONSTRAINT [PK__page_types_accep__1FCDBCEB] PRIMARY KEY CLUSTERED 
(
	[page_type_template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[pages]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[pages](
	[page_id] [int] IDENTITY(1,1) NOT NULL,
	[page_created] [datetime] NOT NULL CONSTRAINT [DF__pages__page_crea__398D8EEE]  DEFAULT (getdate()),
	[page_modified] [datetime] NOT NULL CONSTRAINT [DF__pages__page_modi__3A81B327]  DEFAULT (getdate()),
	[page_name] [nvarchar](190) NOT NULL,
	[page_alias] [nvarchar](190) NOT NULL,
	[page_ordering] [int] NOT NULL CONSTRAINT [DF__pages__page_orde__3B75D760]  DEFAULT ((0)),
	[page_published] [bit] NOT NULL CONSTRAINT [DF__pages__page_publ__3C69FB99]  DEFAULT ((1)),
	[page_link] [nvarchar](190) NULL,
	[page_img] [nvarchar](100) NULL,
	[page_type_id] [int] NULL,
	[page_created_by_id] [int] NULL,
	[page_modified_by_id] [int] NULL,
	[template_id] [int] NULL,
	[language_id] [int] NULL,
	[page_meta] [nvarchar](max) NULL,
	[page_keywords] [nvarchar](max) NULL,
	[page_editable] [bit] NOT NULL CONSTRAINT [DF__pages__page_edit__3D5E1FD2]  DEFAULT ((1)),
	[page_removable] [bit] NOT NULL CONSTRAINT [DF__pages__page_remo__3E52440B]  DEFAULT ((1)),
 CONSTRAINT [PK__pages__38996AB5] PRIMARY KEY CLUSTERED 
(
	[page_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[templates]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[templates](
	[template_id] [int] IDENTITY(1,1) NOT NULL,
	[template_created] [datetime] NOT NULL CONSTRAINT [DF__templates__templ__0CBAE877]  DEFAULT (getdate()),
	[template_modified] [datetime] NOT NULL CONSTRAINT [DF__templates__templ__0DAF0CB0]  DEFAULT (getdate()),
	[template_name] [nvarchar](50) NOT NULL,
	[template_path] [nvarchar](255) NOT NULL,
	[template_description] [nvarchar](255) NULL,
	[template_active] [bit] NOT NULL CONSTRAINT [DF__templates__templ__0EA330E9]  DEFAULT ((1)),
	[language_id] [int] NULL,
	[template_hidden] [bit] NOT NULL CONSTRAINT [DF__templates__templ__0F975522]  DEFAULT ((0)),
 CONSTRAINT [PK__templates__0BC6C43E] PRIMARY KEY CLUSTERED 
(
	[template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[user_languages]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[user_languages](
	[user_language_id] [int] IDENTITY(1,1) NOT NULL,
	[user_language_created] [datetime] NOT NULL CONSTRAINT [DF__user_lang__user___2942188C]  DEFAULT (getdate()),
	[user_language_modified] [datetime] NOT NULL CONSTRAINT [DF__user_lang__user___2A363CC5]  DEFAULT (getdate()),
	[user_id] [int] NOT NULL,
	[language_id] [int] NOT NULL,
 CONSTRAINT [PK__user_languages__284DF453] PRIMARY KEY CLUSTERED 
(
	[user_language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[user_page_types]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[user_page_types](
	[user_page_type_id] [int] IDENTITY(1,1) NOT NULL,
	[user_page_type_created] [datetime] NOT NULL CONSTRAINT [DF__user_page__user___2FEF161B]  DEFAULT (getdate()),
	[user_page_type_modified] [datetime] NOT NULL CONSTRAINT [DF__user_page__user___30E33A54]  DEFAULT (getdate()),
	[user_id] [int] NOT NULL,
	[page_type_id] [int] NOT NULL,
 CONSTRAINT [PK__user_page_types__2EFAF1E2] PRIMARY KEY CLUSTERED 
(
	[user_page_type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[users]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[users](
	[user_id] [int] IDENTITY(1,1) NOT NULL,
	[user_created] [datetime] NOT NULL CONSTRAINT [DF__users__user_crea__7D78A4E7]  DEFAULT (getdate()),
	[user_modified] [datetime] NOT NULL CONSTRAINT [DF__users__user_modi__7E6CC920]  DEFAULT (getdate()),
	[user_login] [nvarchar](50) NOT NULL,
	[user_first_name] [nvarchar](50) NULL,
	[user_last_name] [nvarchar](50) NULL,
	[user_mail_address] [nvarchar](80) NOT NULL,
	[user_pass_hash] [nvarchar](40) NOT NULL,
	[user_pass_salt] [nvarchar](36) NOT NULL,
	[user_active] [bit] NULL CONSTRAINT [DF__users__user_acti__7F60ED59]  DEFAULT ((1)),
	[user_created_by_id] [int] NULL,
	[user_modified_by_id] [int] NULL,
	[user_permission_access] [bit] NULL CONSTRAINT [DF__users__user_perm__2665ABE1]  DEFAULT ((0)),
 CONSTRAINT [PK__users__7C8480AE] PRIMARY KEY CLUSTERED 
(
	[user_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[variable_types]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[variable_types](
	[variable_type_id] [int] IDENTITY(1,1) NOT NULL,
	[variable_type_created] [datetime] NOT NULL CONSTRAINT [DF__variable___varia__52593CB8]  DEFAULT (getdate()),
	[variable_type_modified] [datetime] NOT NULL CONSTRAINT [DF__variable___varia__534D60F1]  DEFAULT (getdate()),
	[variable_type_name] [nvarchar](80) NOT NULL,
	[variable_type_img] [nvarchar](100) NULL,
	[variable_type_description] [nvarchar](255) NULL,
	[variable_type_hidden] [bit] NOT NULL CONSTRAINT [DF__variable___varia__5441852A]  DEFAULT ((0)),
 CONSTRAINT [PK__variable_types__5165187F] PRIMARY KEY CLUSTERED 
(
	[variable_type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[variable_values]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[variable_values](
	[variable_value_id] [int] IDENTITY(1,1) NOT NULL,
	[variable_value_created] [datetime] NOT NULL CONSTRAINT [DF__variable___varia__6477ECF3]  DEFAULT (getdate()),
	[variable_value_modified] [datetime] NOT NULL CONSTRAINT [DF__variable___varia__656C112C]  DEFAULT (getdate()),
	[variable_value_published] [bit] NOT NULL CONSTRAINT [DF__variable___varia__66603565]  DEFAULT ((1)),
	[variable_value] [nvarchar](max) NULL,
	[variable_id] [int] NOT NULL,
	[page_id] [int] NOT NULL,
	[variable_value_created_by_id] [int] NULL,
	[variable_value_modified_by_id] [int] NULL,
 CONSTRAINT [PK__variable_values__6383C8BA] PRIMARY KEY CLUSTERED 
(
	[variable_value_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[variables]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[variables](
	[variable_id] [int] IDENTITY(1,1) NOT NULL,
	[variable_created] [datetime] NOT NULL CONSTRAINT [DF__variables__varia__5812160E]  DEFAULT (getdate()),
	[variable_modified] [datetime] NOT NULL CONSTRAINT [DF__variables__varia__59063A47]  DEFAULT (getdate()),
	[variable_name] [nvarchar](80) NOT NULL,
	[variable_description] [nvarchar](255) NOT NULL,
	[variable_type_id] [int] NOT NULL,
	[variable_created_by_id] [int] NULL,
	[variable_modified_by_id] [int] NULL,
	[variable_editable] [bit] NOT NULL CONSTRAINT [DF__variables__varia__59FA5E80]  DEFAULT ((1)),
	[variable_ordering] [int] NOT NULL CONSTRAINT [DF__variables__varia__5AEE82B9]  DEFAULT ((0)),
	[variable_published] [bit] NOT NULL CONSTRAINT [DF__variables__varia__5BE2A6F2]  DEFAULT ((1)),
	[language_id] [int] NULL,
	[template_id] [int] NULL,
 CONSTRAINT [PK__variables__571DF1D5] PRIMARY KEY CLUSTERED 
(
	[variable_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_engine_models]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_engine_models](
	[engine_model_id] [int] IDENTITY(1,1) NOT NULL,
	[engine_model_created] [datetime] NOT NULL CONSTRAINT [DF__wix_engin__engin__68336F3E]  DEFAULT (getdate()),
	[engine_model_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_engin__engin__69279377]  DEFAULT (getdate()),
	[engine_id] [int] NOT NULL,
	[model_id] [int] NOT NULL,
 CONSTRAINT [PK__wix_engine_model__673F4B05] PRIMARY KEY CLUSTERED 
(
	[engine_model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_engines]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_engines](
	[engine_id] [int] IDENTITY(1,1) NOT NULL,
	[engine_created] [datetime] NOT NULL CONSTRAINT [DF__wix_engin__engin__01D345B0]  DEFAULT (getdate()),
	[engine_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_engin__engin__02C769E9]  DEFAULT (getdate()),
	[engine_name] [nvarchar](100) NOT NULL,
	[engine_description] [nvarchar](255) NULL,
	[engine_cubic_capacity] [nvarchar](255) NULL,
	[engine_code] [nvarchar](255) NULL,
	[engine_horse_power] [nvarchar](255) NULL,
	[engine_year_from] [int] NULL,
	[engine_year_to] [int] NULL,
	[vehicle_id] [int] NOT NULL,
 CONSTRAINT [PK__wix_engines__00DF2177] PRIMARY KEY CLUSTERED 
(
	[engine_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_engine_comments]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_engine_comments](
	[filter_engine_comment_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_engine_comment_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__1AF3F935]  DEFAULT (getdate()),
	[filter_engine_comment_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__1BE81D6E]  DEFAULT (getdate()),
	[filter_engine_id] [int] NOT NULL,
	[filter_additional_info] [nvarchar](400) NULL,
	[applicable_year] [int] NULL,
 CONSTRAINT [PK__wix_filter_engin__190BB0C3] PRIMARY KEY CLUSTERED 
(
	[filter_engine_comment_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_engine_comments_agg]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_engine_comments_agg](
	[filter_engine_comment_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_engine_comment_created] [datetime] NOT NULL,
	[filter_engine_comment_modified] [datetime] NOT NULL,
	[filter_engine_id] [int] NOT NULL,
	[year_from] [int] NULL,
	[year_to] [int] NULL,
	[filter_additional_info] [nvarchar](400) NULL,
 CONSTRAINT [PK__wix_filter_engin__1FB8AE52] PRIMARY KEY CLUSTERED 
(
	[filter_engine_comment_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_engine_footnote]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_engine_footnote](
	[filter_engine_footnote_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_engine_footnote_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__60C757A0]  DEFAULT (getdate()),
	[filter_engine_footnote_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__61BB7BD9]  DEFAULT (getdate()),
	[filter_engine_id] [int] NOT NULL,
	[footnote_id] [int] NOT NULL,
 CONSTRAINT [PK__wix_filter_engin__5FD33367] PRIMARY KEY CLUSTERED 
(
	[filter_engine_footnote_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_engines]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_engines](
	[filter_engine_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_engine_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__51EF2864]  DEFAULT (getdate()),
	[filter_engine_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__52E34C9D]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[engine_id] [int] NOT NULL,
	[model_id] [int] NOT NULL,
	[year_from] [int] NULL,
	[year_to] [int] NULL,
	[filter_additional_info] [nvarchar](500) NULL,
	[filter_other_info] [nvarchar](255) NULL,
 CONSTRAINT [PK__wix_filter_engin__50FB042B] PRIMARY KEY CLUSTERED 
(
	[filter_engine_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_medias]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_medias](
	[media_id] [int] IDENTITY(1,1) NOT NULL,
	[media_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__media__1209AD79]  DEFAULT (getdate()),
	[media_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__media__12FDD1B2]  DEFAULT (getdate()),
	[media_name] [nvarchar](100) NOT NULL,
	[media_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__wix_filter_media__11158940] PRIMARY KEY CLUSTERED 
(
	[media_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_services]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_services](
	[service_id] [int] IDENTITY(1,1) NOT NULL,
	[service_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__servi__640DD89F]  DEFAULT (getdate()),
	[service_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__servi__6501FCD8]  DEFAULT (getdate()),
	[service_name] [nvarchar](100) NOT NULL,
	[service_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__wix_filter_servi__6319B466] PRIMARY KEY CLUSTERED 
(
	[service_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_shapes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_shapes](
	[shape_id] [int] IDENTITY(1,1) NOT NULL,
	[shape_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__shape__1B9317B3]  DEFAULT (getdate()),
	[shape_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__shape__1C873BEC]  DEFAULT (getdate()),
	[shape_name] [nvarchar](100) NOT NULL,
	[shape_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__wix_filter_shape__1A9EF37A] PRIMARY KEY CLUSTERED 
(
	[shape_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_styles]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_styles](
	[style_id] [int] IDENTITY(1,1) NOT NULL,
	[style_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__style__16CE6296]  DEFAULT (getdate()),
	[style_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__style__17C286CF]  DEFAULT (getdate()),
	[style_name] [nvarchar](100) NOT NULL,
	[style_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__wix_filter_style__15DA3E5D] PRIMARY KEY CLUSTERED 
(
	[style_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_type_shapes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_type_shapes](
	[type_shape_id] [int] IDENTITY(1,1) NOT NULL,
	[type_shape_created] [datetime] NOT NULL,
	[type_shape_modified] [datetime] NOT NULL,
	[type_id] [int] NOT NULL,
	[shape_id] [int] NOT NULL,
	[height_dim_available] [bit] NULL,
	[width_dim_available] [bit] NULL,
	[length_dim_available] [bit] NULL,
	[outside_dia_top_dim_available] [bit] NULL,
	[outside_dia_bottom_dim_available] [bit] NULL,
	[inside_dia_top_dim_available] [bit] NULL,
	[inside_dia_bottom_dim_available] [bit] NULL,
 CONSTRAINT [PK__wix_filter_type___1F63A897] PRIMARY KEY CLUSTERED 
(
	[type_shape_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filter_types]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filter_types](
	[type_id] [int] IDENTITY(1,1) NOT NULL,
	[type_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__type___0D44F85C]  DEFAULT (getdate()),
	[type_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__type___0E391C95]  DEFAULT (getdate()),
	[type_name] [nvarchar](100) NOT NULL,
	[type_abbr] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK__wix_filter_types__0C50D423] PRIMARY KEY CLUSTERED 
(
	[type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filters]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filters](
	[filter_id] [int] IDENTITY(1,1) NOT NULL,
	[filter_created] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__2DB1C7EE]  DEFAULT (getdate()),
	[filter_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_filte__filte__2EA5EC27]  DEFAULT (getdate()),
	[filter_number] [nvarchar](100) NOT NULL,
	[filter_number_trim] [nvarchar](100) NOT NULL,
	[filter_type_id] [int] NULL,
	[filter_media_id] [int] NULL,
	[filter_style_id] [int] NULL,
	[filter_shape_id] [int] NULL,
	[filter_height] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__2F9A1060]  DEFAULT ((0)),
	[filter_width] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__308E3499]  DEFAULT ((0)),
	[filter_length] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__318258D2]  DEFAULT ((0)),
	[filter_outside_dia_top] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__32767D0B]  DEFAULT ((0)),
	[filter_outside_dia_bottom] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__336AA144]  DEFAULT ((0)),
	[filter_inside_dia_top] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__345EC57D]  DEFAULT ((0)),
	[filter_inside_dia_bottom] [decimal](18, 4) NOT NULL CONSTRAINT [DF__wix_filte__filte__3552E9B6]  DEFAULT ((0)),
	[filter_cubic_feet_per_minute] [int] NULL CONSTRAINT [DF__wix_filte__filte__36470DEF]  DEFAULT ((0)),
	[filter_micron] [int] NULL CONSTRAINT [DF__wix_filte__filte__373B3228]  DEFAULT ((0)),
	[filter_threads] [nvarchar](80) NULL,
	[filter_thread_size] [nvarchar](80) NULL,
	[filter_ends] [nvarchar](80) NULL,
	[filter_drains] [bit] NULL CONSTRAINT [DF__wix_filte__filte__382F5661]  DEFAULT ((0)),
	[filter_fins] [bit] NULL CONSTRAINT [DF__wix_filte__filte__39237A9A]  DEFAULT ((0)),
	[filter_oval_shaped] [bit] NULL CONSTRAINT [DF__wix_filte__filte__3A179ED3]  DEFAULT ((0)),
	[filter_inlet] [nvarchar](80) NULL,
	[filter_outlet] [nvarchar](80) NULL,
	[filter_vapor] [nvarchar](80) NULL,
	[filter_bpvs] [nvarchar](80) NULL,
	[filter_adbv] [bit] NULL CONSTRAINT [DF__wix_filte__filte__3B0BC30C]  DEFAULT ((0)),
	[filter_pressure_release] [bit] NULL CONSTRAINT [DF__wix_filte__filte__3BFFE745]  DEFAULT ((0)),
	[filter_stand_pipe] [bit] NULL CONSTRAINT [DF__wix_filte__filte__3CF40B7E]  DEFAULT ((0)),
	[filter_anti_siphon_valve] [bit] NULL CONSTRAINT [DF__wix_filte__filte__3DE82FB7]  DEFAULT ((0)),
	[filter_beta_ratio] [nvarchar](80) NULL,
	[filter_tube_layout] [nvarchar](80) NULL,
	[filter_burst_pressure] [int] NULL CONSTRAINT [DF__wix_filte__filte__3EDC53F0]  DEFAULT ((0)),
	[filter_flow_rate] [nvarchar](80) NULL,
	[filter_principle_applications] [nvarchar](max) NULL,
	[filter_image] [nvarchar](255) NULL,
	[filter_service_id] [int] NULL,
 CONSTRAINT [PK__wix_filters__2CBDA3B5] PRIMARY KEY CLUSTERED 
(
	[filter_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_filtron_cross]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_filtron_cross](
	[cross_id] [int] IDENTITY(1,1) NOT NULL,
	[cross_created] [datetime] NOT NULL,
	[cross_modified] [datetime] NOT NULL,
	[wix_filter_id] [int] NOT NULL,
	[filtron_filter_id] [int] NOT NULL,
	[wix_filter_number] [nvarchar](255) NULL,
	[filtron_filter_number] [nvarchar](255) NULL,
	[wix_filter_number_trim] [nvarchar](255) NULL,
	[filtron_filter_number_trim] [nvarchar](255) NULL,
 CONSTRAINT [PK__wix_filtron_cros__57A801BA] PRIMARY KEY CLUSTERED 
(
	[cross_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_footnotes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_footnotes](
	[footnote_id] [int] IDENTITY(1,1) NOT NULL,
	[footnote_created] [datetime] NOT NULL CONSTRAINT [DF__wix_footn__footn__5C02A283]  DEFAULT (getdate()),
	[footnote_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_footn__footn__5CF6C6BC]  DEFAULT (getdate()),
	[footnote_name] [nvarchar](255) NULL,
	[org_footnote_id] [int] NOT NULL,
 CONSTRAINT [PK__wix_footnotes__5B0E7E4A] PRIMARY KEY CLUSTERED 
(
	[footnote_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_interchange_manufacturers]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_interchange_manufacturers](
	[manufacturer_id] [int] IDENTITY(1,1) NOT NULL,
	[manufacturer_created] [datetime] NOT NULL CONSTRAINT [DF__wix_inter__manuf__467D75B8]  DEFAULT (getdate()),
	[manufacturer_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_inter__manuf__477199F1]  DEFAULT (getdate()),
	[manufacturer_name] [nvarchar](100) NOT NULL,
	[manufacturer_description] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK__wix_interchange___4589517F] PRIMARY KEY CLUSTERED 
(
	[manufacturer_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_interchanges]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_interchanges](
	[interchange_id] [int] IDENTITY(1,1) NOT NULL,
	[interchange_created] [datetime] NOT NULL CONSTRAINT [DF__wix_inter__inter__4B422AD5]  DEFAULT (getdate()),
	[interchange_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_inter__inter__4C364F0E]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[manufacturer_id] [int] NOT NULL,
	[foreign_filter_number] [nvarchar](255) NOT NULL,
	[foreign_filter_trim] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK__wix_interchanges__4A4E069C] PRIMARY KEY CLUSTERED 
(
	[interchange_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_logistics_info]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_logistics_info](
	[logistics_info_id] [int] IDENTITY(1,1) NOT NULL,
	[logistics_info_created] [datetime] NOT NULL CONSTRAINT [DF__wix_logis__logis__53F76C67]  DEFAULT (getdate()),
	[logistics_info_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_logis__logis__54EB90A0]  DEFAULT (getdate()),
	[filter_id] [int] NOT NULL,
	[hd] [nvarchar](80) NULL,
	[min_ilosc_zam] [int] NULL,
	[ilosc_zg] [int] NULL,
	[ilosc_pal] [int] NULL,
	[kart_w] [int] NULL,
	[kart_h] [int] NULL,
	[kart_l] [int] NULL,
	[waga] [nvarchar](80) NULL,
	[kod_ean] [nvarchar](80) NULL,
 CONSTRAINT [PK__wix_logistics_in__520F23F5] PRIMARY KEY CLUSTERED 
(
	[logistics_info_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_makes]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_makes](
	[make_id] [int] IDENTITY(1,1) NOT NULL,
	[make_created] [datetime] NOT NULL CONSTRAINT [DF__wix_makes__make___76619304]  DEFAULT (getdate()),
	[make_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_makes__make___7755B73D]  DEFAULT (getdate()),
	[make_name] [nvarchar](100) NOT NULL,
	[make_description] [nvarchar](255) NULL,
	[vehicle_id] [int] NOT NULL,
 CONSTRAINT [PK__wix_makes__756D6ECB] PRIMARY KEY CLUSTERED 
(
	[make_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_models]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_models](
	[model_id] [int] IDENTITY(1,1) NOT NULL,
	[model_created] [datetime] NOT NULL CONSTRAINT [DF__wix_model__model__7C1A6C5A]  DEFAULT (getdate()),
	[model_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_model__model__7D0E9093]  DEFAULT (getdate()),
	[model_name] [nvarchar](100) NOT NULL,
	[model_description] [nvarchar](255) NULL,
	[model_year_from] [int] NULL,
	[model_year_to] [int] NULL,
	[make_id] [int] NOT NULL,
 CONSTRAINT [PK__wix_models__7B264821] PRIMARY KEY CLUSTERED 
(
	[model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[wix_vehicles]    Script Date: 2015-11-11 14:18:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[wix_vehicles](
	[vehicle_id] [int] IDENTITY(1,1) NOT NULL,
	[vehicle_created] [datetime] NOT NULL CONSTRAINT [DF__wix_vehic__vehic__719CDDE7]  DEFAULT (getdate()),
	[vehicle_modified] [datetime] NOT NULL CONSTRAINT [DF__wix_vehic__vehic__72910220]  DEFAULT (getdate()),
	[vehicle_name] [nvarchar](100) NOT NULL,
	[vehicle_description] [nvarchar](255) NULL,
 CONSTRAINT [PK__wix_vehicles__70A8B9AE] PRIMARY KEY CLUSTERED 
(
	[vehicle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Index [filtron_engine_models_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_engine_models_idx0] ON [dbo].[filtron_engine_models]
(
	[engine_id] ASC,
	[model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_engines_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_engines_idx0] ON [dbo].[filtron_engines]
(
	[engine_name] ASC,
	[vehicle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [filtron_filter_engines_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_filter_engines_idx0] ON [dbo].[filtron_filter_engines]
(
	[filter_id] ASC,
	[engine_id] ASC,
	[model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filter_medias_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_filter_medias_idx0] ON [dbo].[filtron_filter_medias]
(
	[media_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filter_shapes_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_filter_shapes_idx0] ON [dbo].[filtron_filter_shapes]
(
	[shape_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filter_styles_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_filter_styles_idx0] ON [dbo].[filtron_filter_styles]
(
	[style_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [filtron_filter_type_shapes_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_filter_type_shapes_idx0] ON [dbo].[filtron_filter_type_shapes]
(
	[type_id] ASC,
	[shape_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filter_types_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_filter_types_idx0] ON [dbo].[filtron_filter_types]
(
	[type_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [filtron_filters_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_filters_idx0] ON [dbo].[filtron_filters]
(
	[filter_dim_a] ASC,
	[filter_dim_b] ASC,
	[filter_dim_h] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [filtron_filters_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_filters_idx1] ON [dbo].[filtron_filters]
(
	[filter_dim_c] ASC,
	[filter_dim_d] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [filtron_filters_idx2]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_filters_idx2] ON [dbo].[filtron_filters]
(
	[filter_dim_e] ASC,
	[filter_dim_f] ASC,
	[filter_dim_g] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filters_idx3]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_filters_idx3] ON [dbo].[filtron_filters]
(
	[filter_number_trim] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filters_idx4]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_filters_idx4] ON [dbo].[filtron_filters]
(
	[filter_wix_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_filters_idx5]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_filters_idx5] ON [dbo].[filtron_filters]
(
	[filter_wix_number_hd] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_interchange_manufacturers_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_interchange_manufacturers_idx0] ON [dbo].[filtron_interchange_manufacturers]
(
	[manufacturer_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_interchanges_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_interchanges_idx0] ON [dbo].[filtron_interchanges]
(
	[filter_id] ASC,
	[foreign_filter_trim] ASC,
	[manufacturer_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_interchanges_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [filtron_interchanges_idx1] ON [dbo].[filtron_interchanges]
(
	[foreign_filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_makes_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_makes_idx0] ON [dbo].[filtron_makes]
(
	[make_name] ASC,
	[vehicle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_models_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_models_idx0] ON [dbo].[filtron_models]
(
	[model_name] ASC,
	[make_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_special_filter_groups_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_special_filter_groups_idx0] ON [dbo].[filtron_special_filter_groups]
(
	[group_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [filtron_special_filters_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_special_filters_idx0] ON [dbo].[filtron_special_filters]
(
	[group_id] ASC,
	[filter_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [filtron_vehicles_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [filtron_vehicles_idx0] ON [dbo].[filtron_vehicles]
(
	[vehicle_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [galleries_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [galleries_idx0] ON [dbo].[galleries]
(
	[gallery_name] ASC,
	[language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [galleries_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [galleries_idx1] ON [dbo].[galleries]
(
	[gallery_ordering] ASC,
	[language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [galleries_idx2]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [galleries_idx2] ON [dbo].[galleries]
(
	[gallery_published] ASC,
	[language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [gallery_images_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [gallery_images_idx0] ON [dbo].[gallery_images]
(
	[gallery_image_ordering] ASC,
	[gallery_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [gallery_images_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [gallery_images_idx1] ON [dbo].[gallery_images]
(
	[gallery_image_published] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_filtry_bac_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_filtry_bac_idx0] ON [dbo].[import_filtron_filtry_bac]
(
	[IDfiltr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_firmy_bac_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_firmy_bac_idx0] ON [dbo].[import_filtron_firmy_bac]
(
	[IDFirma] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_katalog_bac_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_katalog_bac_idx0] ON [dbo].[import_filtron_katalog_bac]
(
	[IDtyp] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_katalog_bac_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_katalog_bac_idx1] ON [dbo].[import_filtron_katalog_bac]
(
	[IDmarka] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_katalog_bac_idx2]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_katalog_bac_idx2] ON [dbo].[import_filtron_katalog_bac]
(
	[IDmodel] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_katalog_bac_idx3]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_katalog_bac_idx3] ON [dbo].[import_filtron_katalog_bac]
(
	[Identyfikator] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_filtron_logistics_info_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [import_filtron_logistics_info_idx0] ON [dbo].[import_filtron_logistics_info]
(
	[filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_marka_bac_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_marka_bac_idx0] ON [dbo].[import_filtron_marka_bac]
(
	[IDmarka] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_model_bac_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_model_bac_idx0] ON [dbo].[import_filtron_model_bac]
(
	[IDmodel] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_filtron_oe_producers_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [import_filtron_oe_producers_idx0] ON [dbo].[import_filtron_oe_producers]
(
	[producer_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_zamienniki_bac_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_zamienniki_bac_idx0] ON [dbo].[import_filtron_zamienniki_bac]
(
	[IDfiltr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_zamienniki_bac_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_zamienniki_bac_idx1] ON [dbo].[import_filtron_zamienniki_bac]
(
	[IDfirma] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [import_filtron_zamienniki_bac_idx2]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_filtron_zamienniki_bac_idx2] ON [dbo].[import_filtron_zamienniki_bac]
(
	[IDzamienniki] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_wix_bus_track_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_wix_bus_track_idx0] ON [dbo].[import_wix_bus_track]
(
	[bus_track_engine] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_wix_bus_track_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_wix_bus_track_idx1] ON [dbo].[import_wix_bus_track]
(
	[bus_track_filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_wix_filters_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_wix_filters_idx0] ON [dbo].[import_wix_filters]
(
	[filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_wix_interchanges_idx_0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_wix_interchanges_idx_0] ON [dbo].[import_wix_interchanges]
(
	[filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_wix_off_highway_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_wix_off_highway_idx0] ON [dbo].[import_wix_off_highway]
(
	[off_highway_engine] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [import_wix_off_highway_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [import_wix_off_highway_idx1] ON [dbo].[import_wix_off_highway]
(
	[off_highway_filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [derived_import_table_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [derived_import_table_idx0] ON [dbo].[import_wix_passenger]
(
	[passenger_filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [languages_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [languages_idx0] ON [dbo].[languages]
(
	[language_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [menu_item_types_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [menu_item_types_idx0] ON [dbo].[menu_item_types]
(
	[type_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [menu_item_types_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [menu_item_types_idx1] ON [dbo].[menu_item_types]
(
	[type_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [menu_item_types_idx2]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [menu_item_types_idx2] ON [dbo].[menu_item_types]
(
	[type_hidden] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [menu_items_idx0]    Script Date: 2015-11-11 14:18:40 ******/
CREATE UNIQUE NONCLUSTERED INDEX [menu_items_idx0] ON [dbo].[menu_items]
(
	[item_link] ASC,
	[menu_id] ASC,
	[item_alias] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [menu_items_idx1]    Script Date: 2015-11-11 14:18:40 ******/
CREATE NONCLUSTERED INDEX [menu_items_idx1] ON [dbo].[menu_items]
(
	[item_ordering] ASC,
	[menu_id] ASC,
	[item_depth] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [menu_items_idx2]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [menu_items_idx2] ON [dbo].[menu_items]
(
	[item_published] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [menus_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [menus_idx0] ON [dbo].[menus]
(
	[menu_name] ASC,
	[language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [menus_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [menus_idx1] ON [dbo].[menus]
(
	[menu_hidden] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [modules_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [modules_idx0] ON [dbo].[modules]
(
	[module_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [modules_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [modules_idx1] ON [dbo].[modules]
(
	[language_id] ASC,
	[module_link] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [modules_templates_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [modules_templates_idx0] ON [dbo].[modules_templates]
(
	[module_id] ASC,
	[template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [page_types_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [page_types_idx0] ON [dbo].[page_types]
(
	[language_id] ASC,
	[page_type_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [page_types_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [page_types_idx1] ON [dbo].[page_types]
(
	[language_id] ASC,
	[page_type_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [page_types_acceptable_templates_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [page_types_acceptable_templates_idx0] ON [dbo].[page_types_acceptable_templates]
(
	[page_type_id] ASC,
	[template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [pages_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [pages_idx0] ON [dbo].[pages]
(
	[language_id] ASC,
	[page_link] ASC,
	[page_alias] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [pages_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [pages_idx1] ON [dbo].[pages]
(
	[page_published] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [pages_idx2]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [pages_idx2] ON [dbo].[pages]
(
	[page_ordering] ASC,
	[page_type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [templates_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [templates_idx0] ON [dbo].[templates]
(
	[language_id] ASC,
	[template_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [templates_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [templates_idx1] ON [dbo].[templates]
(
	[language_id] ASC,
	[template_path] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [user_languages_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [user_languages_idx0] ON [dbo].[user_languages]
(
	[user_id] ASC,
	[language_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [user_page_types_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [user_page_types_idx0] ON [dbo].[user_page_types]
(
	[user_id] ASC,
	[page_type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [users_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [users_idx0] ON [dbo].[users]
(
	[user_login] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [users_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [users_idx1] ON [dbo].[users]
(
	[user_mail_address] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [users_idx2]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [users_idx2] ON [dbo].[users]
(
	[user_first_name] ASC,
	[user_last_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [variable_types_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [variable_types_idx0] ON [dbo].[variable_types]
(
	[variable_type_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [variable_types_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [variable_types_idx1] ON [dbo].[variable_types]
(
	[variable_type_hidden] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [variable_values_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [variable_values_idx0] ON [dbo].[variable_values]
(
	[variable_id] ASC,
	[page_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [variable_values_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [variable_values_idx1] ON [dbo].[variable_values]
(
	[variable_value_published] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [variables_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [variables_idx0] ON [dbo].[variables]
(
	[variable_name] ASC,
	[language_id] ASC,
	[template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [variables_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [variables_idx1] ON [dbo].[variables]
(
	[variable_ordering] ASC,
	[language_id] ASC,
	[template_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [variables_idx2]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [variables_idx2] ON [dbo].[variables]
(
	[variable_published] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_engines_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_engines_idx0] ON [dbo].[wix_engines]
(
	[engine_name] ASC,
	[vehicle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_engine_comments_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_filter_engine_comments_idx0] ON [dbo].[wix_filter_engine_comments]
(
	[filter_additional_info] ASC,
	[filter_engine_id] ASC,
	[applicable_year] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_engine_comments_agg_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_filter_engine_comments_agg_idx0] ON [dbo].[wix_filter_engine_comments_agg]
(
	[filter_additional_info] ASC,
	[filter_engine_id] ASC,
	[year_from] ASC,
	[year_to] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filter_engine_footnote_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_filter_engine_footnote_idx0] ON [dbo].[wix_filter_engine_footnote]
(
	[filter_engine_id] ASC,
	[footnote_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filter_engines_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_engines_idx0] ON [dbo].[wix_filter_engines]
(
	[filter_id] ASC,
	[engine_id] ASC,
	[model_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_medias_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_medias_idx0] ON [dbo].[wix_filter_medias]
(
	[media_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_services_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_services_idx0] ON [dbo].[wix_filter_services]
(
	[service_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_shapes_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_shapes_idx0] ON [dbo].[wix_filter_shapes]
(
	[shape_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_styles_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_styles_idx0] ON [dbo].[wix_filter_styles]
(
	[style_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filter_type_shapes_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_type_shapes_idx0] ON [dbo].[wix_filter_type_shapes]
(
	[type_id] ASC,
	[shape_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filter_types_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filter_types_idx0] ON [dbo].[wix_filter_types]
(
	[type_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filters_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_filters_idx0] ON [dbo].[wix_filters]
(
	[filter_height] ASC,
	[filter_width] ASC,
	[filter_length] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filters_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_filters_idx1] ON [dbo].[wix_filters]
(
	[filter_outside_dia_top] ASC,
	[filter_outside_dia_bottom] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filters_idx2]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_filters_idx2] ON [dbo].[wix_filters]
(
	[filter_inside_dia_top] ASC,
	[filter_inside_dia_bottom] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_filters_idx3]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filters_idx3] ON [dbo].[wix_filters]
(
	[filter_number_trim] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_filtron_cross_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_filtron_cross_idx0] ON [dbo].[wix_filtron_cross]
(
	[wix_filter_id] ASC,
	[filtron_filter_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [wix_footnotes_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_footnotes_idx1] ON [dbo].[wix_footnotes]
(
	[org_footnote_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_interchange_manufacturers_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_interchange_manufacturers_idx0] ON [dbo].[wix_interchange_manufacturers]
(
	[manufacturer_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_interchanges_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_interchanges_idx0] ON [dbo].[wix_interchanges]
(
	[filter_id] ASC,
	[foreign_filter_trim] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_interchanges_idx1]    Script Date: 2015-11-11 14:18:41 ******/
CREATE NONCLUSTERED INDEX [wix_interchanges_idx1] ON [dbo].[wix_interchanges]
(
	[foreign_filter_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_makes_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_makes_idx0] ON [dbo].[wix_makes]
(
	[make_name] ASC,
	[vehicle_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_models_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_models_idx0] ON [dbo].[wix_models]
(
	[model_name] ASC,
	[make_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [wix_vehicles_idx0]    Script Date: 2015-11-11 14:18:41 ******/
CREATE UNIQUE NONCLUSTERED INDEX [wix_vehicles_idx0] ON [dbo].[wix_vehicles]
(
	[vehicle_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__ext_d__38845C1C]  DEFAULT (getdate()) FOR [ext_dim_dict_created]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__ext_d__39788055]  DEFAULT (getdate()) FOR [ext_dim_dict_modified]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_a__3A6CA48E]  DEFAULT ((0)) FOR [dim_a_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_b__3B60C8C7]  DEFAULT ((0)) FOR [dim_b_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_c__3C54ED00]  DEFAULT ((0)) FOR [dim_c_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_d__3D491139]  DEFAULT ((0)) FOR [dim_d_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_e__3E3D3572]  DEFAULT ((0)) FOR [dim_e_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_f__3F3159AB]  DEFAULT ((0)) FOR [dim_f_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_g__40257DE4]  DEFAULT ((0)) FOR [dim_g_available]
GO
ALTER TABLE [dbo].[import_filtron_ext_dim_dict] ADD  CONSTRAINT [DF__import_fi__dim_h__4119A21D]  DEFAULT ((0)) FOR [dim_h_available]
GO
ALTER TABLE [dbo].[wix_filter_engine_comments_agg] ADD  CONSTRAINT [DF__wix_filte__filte__21A0F6C4]  DEFAULT (getdate()) FOR [filter_engine_comment_created]
GO
ALTER TABLE [dbo].[wix_filter_engine_comments_agg] ADD  CONSTRAINT [DF__wix_filte__filte__22951AFD]  DEFAULT (getdate()) FOR [filter_engine_comment_modified]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__type___2057CCD0]  DEFAULT (getdate()) FOR [type_shape_created]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__type___214BF109]  DEFAULT (getdate()) FOR [type_shape_modified]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__heigh__22401542]  DEFAULT ((0)) FOR [height_dim_available]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__width__2334397B]  DEFAULT ((0)) FOR [width_dim_available]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__lengt__24285DB4]  DEFAULT ((0)) FOR [length_dim_available]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__outsi__251C81ED]  DEFAULT ((0)) FOR [outside_dia_top_dim_available]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__outsi__2610A626]  DEFAULT ((0)) FOR [outside_dia_bottom_dim_available]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__insid__2704CA5F]  DEFAULT ((0)) FOR [inside_dia_top_dim_available]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] ADD  CONSTRAINT [DF__wix_filte__insid__27F8EE98]  DEFAULT ((0)) FOR [inside_dia_bottom_dim_available]
GO
ALTER TABLE [dbo].[wix_filtron_cross] ADD  CONSTRAINT [DF__wix_filtr__cross__589C25F3]  DEFAULT (getdate()) FOR [cross_created]
GO
ALTER TABLE [dbo].[wix_filtron_cross] ADD  CONSTRAINT [DF__wix_filtr__cross__59904A2C]  DEFAULT (getdate()) FOR [cross_modified]
GO
ALTER TABLE [dbo].[filtron_engine_models]  WITH CHECK ADD  CONSTRAINT [filtron_engine_models_fk0] FOREIGN KEY([model_id])
REFERENCES [dbo].[filtron_models] ([model_id])
GO
ALTER TABLE [dbo].[filtron_engine_models] CHECK CONSTRAINT [filtron_engine_models_fk0]
GO
ALTER TABLE [dbo].[filtron_engine_models]  WITH CHECK ADD  CONSTRAINT [filtron_engine_models_fk1] FOREIGN KEY([engine_id])
REFERENCES [dbo].[filtron_engines] ([engine_id])
GO
ALTER TABLE [dbo].[filtron_engine_models] CHECK CONSTRAINT [filtron_engine_models_fk1]
GO
ALTER TABLE [dbo].[filtron_engines]  WITH CHECK ADD  CONSTRAINT [filtron_engines_fk0] FOREIGN KEY([vehicle_id])
REFERENCES [dbo].[filtron_vehicles] ([vehicle_id])
GO
ALTER TABLE [dbo].[filtron_engines] CHECK CONSTRAINT [filtron_engines_fk0]
GO
ALTER TABLE [dbo].[filtron_filter_engine_comments]  WITH CHECK ADD  CONSTRAINT [filtron_filter_engine_comments_fk0] FOREIGN KEY([filter_engine_id])
REFERENCES [dbo].[filtron_filter_engines] ([filter_engine_id])
GO
ALTER TABLE [dbo].[filtron_filter_engine_comments] CHECK CONSTRAINT [filtron_filter_engine_comments_fk0]
GO
ALTER TABLE [dbo].[filtron_filter_engines]  WITH CHECK ADD  CONSTRAINT [filtron_filter_engines_fk0] FOREIGN KEY([filter_id])
REFERENCES [dbo].[filtron_filters] ([filter_id])
GO
ALTER TABLE [dbo].[filtron_filter_engines] CHECK CONSTRAINT [filtron_filter_engines_fk0]
GO
ALTER TABLE [dbo].[filtron_filter_engines]  WITH CHECK ADD  CONSTRAINT [filtron_filter_engines_fk1] FOREIGN KEY([engine_id])
REFERENCES [dbo].[filtron_engines] ([engine_id])
GO
ALTER TABLE [dbo].[filtron_filter_engines] CHECK CONSTRAINT [filtron_filter_engines_fk1]
GO
ALTER TABLE [dbo].[filtron_filter_engines]  WITH CHECK ADD  CONSTRAINT [filtron_filter_engines_fk2] FOREIGN KEY([model_id])
REFERENCES [dbo].[filtron_models] ([model_id])
GO
ALTER TABLE [dbo].[filtron_filter_engines] CHECK CONSTRAINT [filtron_filter_engines_fk2]
GO
ALTER TABLE [dbo].[filtron_filter_type_shapes]  WITH CHECK ADD  CONSTRAINT [filtron_filter_type_shapes_fk0] FOREIGN KEY([type_id])
REFERENCES [dbo].[filtron_filter_types] ([type_id])
GO
ALTER TABLE [dbo].[filtron_filter_type_shapes] CHECK CONSTRAINT [filtron_filter_type_shapes_fk0]
GO
ALTER TABLE [dbo].[filtron_filter_type_shapes]  WITH CHECK ADD  CONSTRAINT [filtron_filter_type_shapes_fk1] FOREIGN KEY([shape_id])
REFERENCES [dbo].[filtron_filter_shapes] ([shape_id])
GO
ALTER TABLE [dbo].[filtron_filter_type_shapes] CHECK CONSTRAINT [filtron_filter_type_shapes_fk1]
GO
ALTER TABLE [dbo].[filtron_filters]  WITH CHECK ADD  CONSTRAINT [filtron_filters_fk0] FOREIGN KEY([filter_type_id])
REFERENCES [dbo].[filtron_filter_types] ([type_id])
GO
ALTER TABLE [dbo].[filtron_filters] CHECK CONSTRAINT [filtron_filters_fk0]
GO
ALTER TABLE [dbo].[filtron_filters]  WITH CHECK ADD  CONSTRAINT [filtron_filters_fk2] FOREIGN KEY([filter_style_id])
REFERENCES [dbo].[filtron_filter_styles] ([style_id])
GO
ALTER TABLE [dbo].[filtron_filters] CHECK CONSTRAINT [filtron_filters_fk2]
GO
ALTER TABLE [dbo].[filtron_filters]  WITH CHECK ADD  CONSTRAINT [filtron_filters_fk3] FOREIGN KEY([filter_shape_id])
REFERENCES [dbo].[filtron_filter_shapes] ([shape_id])
GO
ALTER TABLE [dbo].[filtron_filters] CHECK CONSTRAINT [filtron_filters_fk3]
GO
ALTER TABLE [dbo].[filtron_interchanges]  WITH CHECK ADD  CONSTRAINT [filtron_interchanges_fk0] FOREIGN KEY([filter_id])
REFERENCES [dbo].[filtron_filters] ([filter_id])
GO
ALTER TABLE [dbo].[filtron_interchanges] CHECK CONSTRAINT [filtron_interchanges_fk0]
GO
ALTER TABLE [dbo].[filtron_interchanges]  WITH CHECK ADD  CONSTRAINT [filtron_interchanges_fk1] FOREIGN KEY([manufacturer_id])
REFERENCES [dbo].[filtron_interchange_manufacturers] ([manufacturer_id])
GO
ALTER TABLE [dbo].[filtron_interchanges] CHECK CONSTRAINT [filtron_interchanges_fk1]
GO
ALTER TABLE [dbo].[filtron_logistics_info]  WITH CHECK ADD  CONSTRAINT [filtron_logistics_info_fk0] FOREIGN KEY([filter_id])
REFERENCES [dbo].[filtron_filters] ([filter_id])
GO
ALTER TABLE [dbo].[filtron_logistics_info] CHECK CONSTRAINT [filtron_logistics_info_fk0]
GO
ALTER TABLE [dbo].[filtron_makes]  WITH CHECK ADD  CONSTRAINT [filtron_makes_fk0] FOREIGN KEY([vehicle_id])
REFERENCES [dbo].[filtron_vehicles] ([vehicle_id])
GO
ALTER TABLE [dbo].[filtron_makes] CHECK CONSTRAINT [filtron_makes_fk0]
GO
ALTER TABLE [dbo].[filtron_models]  WITH CHECK ADD  CONSTRAINT [filtron_models_fk0] FOREIGN KEY([make_id])
REFERENCES [dbo].[filtron_makes] ([make_id])
GO
ALTER TABLE [dbo].[filtron_models] CHECK CONSTRAINT [filtron_models_fk0]
GO
ALTER TABLE [dbo].[filtron_special_filters]  WITH CHECK ADD  CONSTRAINT [filtron_special_filters_fk0] FOREIGN KEY([group_id])
REFERENCES [dbo].[filtron_special_filter_groups] ([group_id])
GO
ALTER TABLE [dbo].[filtron_special_filters] CHECK CONSTRAINT [filtron_special_filters_fk0]
GO
ALTER TABLE [dbo].[filtron_special_filters]  WITH CHECK ADD  CONSTRAINT [filtron_special_filters_fk1] FOREIGN KEY([filter_id])
REFERENCES [dbo].[filtron_filters] ([filter_id])
GO
ALTER TABLE [dbo].[filtron_special_filters] CHECK CONSTRAINT [filtron_special_filters_fk1]
GO
ALTER TABLE [dbo].[galleries]  WITH CHECK ADD  CONSTRAINT [galleries_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[galleries] CHECK CONSTRAINT [galleries_fk0]
GO
ALTER TABLE [dbo].[galleries]  WITH CHECK ADD  CONSTRAINT [galleries_fk1] FOREIGN KEY([module_id])
REFERENCES [dbo].[modules] ([module_id])
GO
ALTER TABLE [dbo].[galleries] CHECK CONSTRAINT [galleries_fk1]
GO
ALTER TABLE [dbo].[galleries]  WITH CHECK ADD  CONSTRAINT [galleries_fk2] FOREIGN KEY([template_id])
REFERENCES [dbo].[templates] ([template_id])
GO
ALTER TABLE [dbo].[galleries] CHECK CONSTRAINT [galleries_fk2]
GO
ALTER TABLE [dbo].[galleries]  WITH CHECK ADD  CONSTRAINT [galleries_fk3] FOREIGN KEY([gallery_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[galleries] CHECK CONSTRAINT [galleries_fk3]
GO
ALTER TABLE [dbo].[galleries]  WITH CHECK ADD  CONSTRAINT [galleries_fk4] FOREIGN KEY([gallery_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[galleries] CHECK CONSTRAINT [galleries_fk4]
GO
ALTER TABLE [dbo].[gallery_images]  WITH CHECK ADD  CONSTRAINT [gallery_images_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[gallery_images] CHECK CONSTRAINT [gallery_images_fk0]
GO
ALTER TABLE [dbo].[gallery_images]  WITH CHECK ADD  CONSTRAINT [gallery_images_fk1] FOREIGN KEY([gallery_id])
REFERENCES [dbo].[galleries] ([gallery_id])
GO
ALTER TABLE [dbo].[gallery_images] CHECK CONSTRAINT [gallery_images_fk1]
GO
ALTER TABLE [dbo].[gallery_images]  WITH CHECK ADD  CONSTRAINT [gallery_images_fk2] FOREIGN KEY([page_id])
REFERENCES [dbo].[pages] ([page_id])
GO
ALTER TABLE [dbo].[gallery_images] CHECK CONSTRAINT [gallery_images_fk2]
GO
ALTER TABLE [dbo].[gallery_images]  WITH CHECK ADD  CONSTRAINT [gallery_images_fk3] FOREIGN KEY([gallery_image_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[gallery_images] CHECK CONSTRAINT [gallery_images_fk3]
GO
ALTER TABLE [dbo].[gallery_images]  WITH CHECK ADD  CONSTRAINT [gallery_images_fk4] FOREIGN KEY([gallery_image_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[gallery_images] CHECK CONSTRAINT [gallery_images_fk4]
GO
ALTER TABLE [dbo].[languages]  WITH CHECK ADD  CONSTRAINT [languages_fk0] FOREIGN KEY([language_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[languages] CHECK CONSTRAINT [languages_fk0]
GO
ALTER TABLE [dbo].[languages]  WITH CHECK ADD  CONSTRAINT [languages_fk1] FOREIGN KEY([language_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[languages] CHECK CONSTRAINT [languages_fk1]
GO
ALTER TABLE [dbo].[last_searches]  WITH CHECK ADD  CONSTRAINT [last_searches_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[last_searches] CHECK CONSTRAINT [last_searches_fk0]
GO
ALTER TABLE [dbo].[menu_items]  WITH CHECK ADD  CONSTRAINT [menu_items_fk0] FOREIGN KEY([item_type_id])
REFERENCES [dbo].[menu_item_types] ([type_id])
GO
ALTER TABLE [dbo].[menu_items] CHECK CONSTRAINT [menu_items_fk0]
GO
ALTER TABLE [dbo].[menu_items]  WITH CHECK ADD  CONSTRAINT [menu_items_fk1] FOREIGN KEY([parent_item_id])
REFERENCES [dbo].[menu_items] ([item_id])
GO
ALTER TABLE [dbo].[menu_items] CHECK CONSTRAINT [menu_items_fk1]
GO
ALTER TABLE [dbo].[menu_items]  WITH CHECK ADD  CONSTRAINT [menu_items_fk2] FOREIGN KEY([item_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[menu_items] CHECK CONSTRAINT [menu_items_fk2]
GO
ALTER TABLE [dbo].[menu_items]  WITH CHECK ADD  CONSTRAINT [menu_items_fk3] FOREIGN KEY([item_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[menu_items] CHECK CONSTRAINT [menu_items_fk3]
GO
ALTER TABLE [dbo].[menu_items]  WITH CHECK ADD  CONSTRAINT [menu_items_fk4] FOREIGN KEY([menu_id])
REFERENCES [dbo].[menus] ([menu_id])
GO
ALTER TABLE [dbo].[menu_items] CHECK CONSTRAINT [menu_items_fk4]
GO
ALTER TABLE [dbo].[menu_items]  WITH CHECK ADD  CONSTRAINT [menu_items_fk5] FOREIGN KEY([page_id])
REFERENCES [dbo].[pages] ([page_id])
GO
ALTER TABLE [dbo].[menu_items] CHECK CONSTRAINT [menu_items_fk5]
GO
ALTER TABLE [dbo].[menus]  WITH CHECK ADD  CONSTRAINT [menus_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[menus] CHECK CONSTRAINT [menus_fk0]
GO
ALTER TABLE [dbo].[menus]  WITH CHECK ADD  CONSTRAINT [menus_fk1] FOREIGN KEY([module_id])
REFERENCES [dbo].[modules] ([module_id])
GO
ALTER TABLE [dbo].[menus] CHECK CONSTRAINT [menus_fk1]
GO
ALTER TABLE [dbo].[modules]  WITH CHECK ADD  CONSTRAINT [modules_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[modules] CHECK CONSTRAINT [modules_fk0]
GO
ALTER TABLE [dbo].[modules_templates]  WITH CHECK ADD  CONSTRAINT [modules_templates_fk0] FOREIGN KEY([module_id])
REFERENCES [dbo].[modules] ([module_id])
GO
ALTER TABLE [dbo].[modules_templates] CHECK CONSTRAINT [modules_templates_fk0]
GO
ALTER TABLE [dbo].[modules_templates]  WITH CHECK ADD  CONSTRAINT [modules_templates_fk1] FOREIGN KEY([template_id])
REFERENCES [dbo].[templates] ([template_id])
GO
ALTER TABLE [dbo].[modules_templates] CHECK CONSTRAINT [modules_templates_fk1]
GO
ALTER TABLE [dbo].[page_types]  WITH CHECK ADD  CONSTRAINT [page_types_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[page_types] CHECK CONSTRAINT [page_types_fk0]
GO
ALTER TABLE [dbo].[page_types_acceptable_templates]  WITH CHECK ADD  CONSTRAINT [page_types_acceptable_templates_fk0] FOREIGN KEY([page_type_id])
REFERENCES [dbo].[page_types] ([page_type_id])
GO
ALTER TABLE [dbo].[page_types_acceptable_templates] CHECK CONSTRAINT [page_types_acceptable_templates_fk0]
GO
ALTER TABLE [dbo].[page_types_acceptable_templates]  WITH CHECK ADD  CONSTRAINT [page_types_acceptable_templates_fk1] FOREIGN KEY([template_id])
REFERENCES [dbo].[templates] ([template_id])
GO
ALTER TABLE [dbo].[page_types_acceptable_templates] CHECK CONSTRAINT [page_types_acceptable_templates_fk1]
GO
ALTER TABLE [dbo].[pages]  WITH CHECK ADD  CONSTRAINT [pages_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[pages] CHECK CONSTRAINT [pages_fk0]
GO
ALTER TABLE [dbo].[pages]  WITH CHECK ADD  CONSTRAINT [pages_fk1] FOREIGN KEY([page_type_id])
REFERENCES [dbo].[page_types] ([page_type_id])
GO
ALTER TABLE [dbo].[pages] CHECK CONSTRAINT [pages_fk1]
GO
ALTER TABLE [dbo].[pages]  WITH CHECK ADD  CONSTRAINT [pages_fk2] FOREIGN KEY([template_id])
REFERENCES [dbo].[templates] ([template_id])
GO
ALTER TABLE [dbo].[pages] CHECK CONSTRAINT [pages_fk2]
GO
ALTER TABLE [dbo].[pages]  WITH CHECK ADD  CONSTRAINT [pages_fk3] FOREIGN KEY([page_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[pages] CHECK CONSTRAINT [pages_fk3]
GO
ALTER TABLE [dbo].[pages]  WITH CHECK ADD  CONSTRAINT [pages_fk4] FOREIGN KEY([page_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[pages] CHECK CONSTRAINT [pages_fk4]
GO
ALTER TABLE [dbo].[templates]  WITH CHECK ADD  CONSTRAINT [templates_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[templates] CHECK CONSTRAINT [templates_fk0]
GO
ALTER TABLE [dbo].[user_languages]  WITH CHECK ADD  CONSTRAINT [user_languages_fk0] FOREIGN KEY([user_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[user_languages] CHECK CONSTRAINT [user_languages_fk0]
GO
ALTER TABLE [dbo].[user_languages]  WITH CHECK ADD  CONSTRAINT [user_languages_fk1] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[user_languages] CHECK CONSTRAINT [user_languages_fk1]
GO
ALTER TABLE [dbo].[user_page_types]  WITH CHECK ADD  CONSTRAINT [user_page_types_fk0] FOREIGN KEY([user_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[user_page_types] CHECK CONSTRAINT [user_page_types_fk0]
GO
ALTER TABLE [dbo].[user_page_types]  WITH CHECK ADD  CONSTRAINT [user_page_types_fk1] FOREIGN KEY([page_type_id])
REFERENCES [dbo].[page_types] ([page_type_id])
GO
ALTER TABLE [dbo].[user_page_types] CHECK CONSTRAINT [user_page_types_fk1]
GO
ALTER TABLE [dbo].[users]  WITH CHECK ADD  CONSTRAINT [users_fk0] FOREIGN KEY([user_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[users] CHECK CONSTRAINT [users_fk0]
GO
ALTER TABLE [dbo].[users]  WITH CHECK ADD  CONSTRAINT [users_fk1] FOREIGN KEY([user_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[users] CHECK CONSTRAINT [users_fk1]
GO
ALTER TABLE [dbo].[variable_values]  WITH CHECK ADD  CONSTRAINT [variable_values_fk0] FOREIGN KEY([variable_id])
REFERENCES [dbo].[variables] ([variable_id])
GO
ALTER TABLE [dbo].[variable_values] CHECK CONSTRAINT [variable_values_fk0]
GO
ALTER TABLE [dbo].[variable_values]  WITH CHECK ADD  CONSTRAINT [variable_values_fk1] FOREIGN KEY([page_id])
REFERENCES [dbo].[pages] ([page_id])
GO
ALTER TABLE [dbo].[variable_values] CHECK CONSTRAINT [variable_values_fk1]
GO
ALTER TABLE [dbo].[variable_values]  WITH CHECK ADD  CONSTRAINT [variable_values_fk2] FOREIGN KEY([variable_value_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[variable_values] CHECK CONSTRAINT [variable_values_fk2]
GO
ALTER TABLE [dbo].[variable_values]  WITH CHECK ADD  CONSTRAINT [variable_values_fk3] FOREIGN KEY([variable_value_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[variable_values] CHECK CONSTRAINT [variable_values_fk3]
GO
ALTER TABLE [dbo].[variables]  WITH CHECK ADD  CONSTRAINT [variables_fk0] FOREIGN KEY([language_id])
REFERENCES [dbo].[languages] ([language_id])
GO
ALTER TABLE [dbo].[variables] CHECK CONSTRAINT [variables_fk0]
GO
ALTER TABLE [dbo].[variables]  WITH CHECK ADD  CONSTRAINT [variables_fk1] FOREIGN KEY([template_id])
REFERENCES [dbo].[templates] ([template_id])
GO
ALTER TABLE [dbo].[variables] CHECK CONSTRAINT [variables_fk1]
GO
ALTER TABLE [dbo].[variables]  WITH CHECK ADD  CONSTRAINT [variables_fk2] FOREIGN KEY([variable_type_id])
REFERENCES [dbo].[variable_types] ([variable_type_id])
GO
ALTER TABLE [dbo].[variables] CHECK CONSTRAINT [variables_fk2]
GO
ALTER TABLE [dbo].[variables]  WITH CHECK ADD  CONSTRAINT [variables_fk3] FOREIGN KEY([variable_created_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[variables] CHECK CONSTRAINT [variables_fk3]
GO
ALTER TABLE [dbo].[variables]  WITH CHECK ADD  CONSTRAINT [variables_fk4] FOREIGN KEY([variable_modified_by_id])
REFERENCES [dbo].[users] ([user_id])
GO
ALTER TABLE [dbo].[variables] CHECK CONSTRAINT [variables_fk4]
GO
ALTER TABLE [dbo].[wix_engine_models]  WITH CHECK ADD  CONSTRAINT [wix_engine_models_fk0] FOREIGN KEY([model_id])
REFERENCES [dbo].[wix_models] ([model_id])
GO
ALTER TABLE [dbo].[wix_engine_models] CHECK CONSTRAINT [wix_engine_models_fk0]
GO
ALTER TABLE [dbo].[wix_engine_models]  WITH CHECK ADD  CONSTRAINT [wix_engine_models_fk1] FOREIGN KEY([engine_id])
REFERENCES [dbo].[wix_engines] ([engine_id])
GO
ALTER TABLE [dbo].[wix_engine_models] CHECK CONSTRAINT [wix_engine_models_fk1]
GO
ALTER TABLE [dbo].[wix_engines]  WITH CHECK ADD  CONSTRAINT [wix_engines_fk0] FOREIGN KEY([vehicle_id])
REFERENCES [dbo].[wix_vehicles] ([vehicle_id])
GO
ALTER TABLE [dbo].[wix_engines] CHECK CONSTRAINT [wix_engines_fk0]
GO
ALTER TABLE [dbo].[wix_filter_engine_comments]  WITH CHECK ADD  CONSTRAINT [wix_filter_engine_comments_fk0] FOREIGN KEY([filter_engine_id])
REFERENCES [dbo].[wix_filter_engines] ([filter_engine_id])
GO
ALTER TABLE [dbo].[wix_filter_engine_comments] CHECK CONSTRAINT [wix_filter_engine_comments_fk0]
GO
ALTER TABLE [dbo].[wix_filter_engine_comments_agg]  WITH CHECK ADD  CONSTRAINT [wix_filter_engine_comments_agg_fk0] FOREIGN KEY([filter_engine_id])
REFERENCES [dbo].[wix_filter_engines] ([filter_engine_id])
GO
ALTER TABLE [dbo].[wix_filter_engine_comments_agg] CHECK CONSTRAINT [wix_filter_engine_comments_agg_fk0]
GO
ALTER TABLE [dbo].[wix_filter_engine_footnote]  WITH CHECK ADD  CONSTRAINT [wix_filter_engine_footnote_fk0] FOREIGN KEY([filter_engine_id])
REFERENCES [dbo].[wix_filter_engines] ([filter_engine_id])
GO
ALTER TABLE [dbo].[wix_filter_engine_footnote] CHECK CONSTRAINT [wix_filter_engine_footnote_fk0]
GO
ALTER TABLE [dbo].[wix_filter_engine_footnote]  WITH CHECK ADD  CONSTRAINT [wix_filter_engine_footnote_fk1] FOREIGN KEY([footnote_id])
REFERENCES [dbo].[wix_footnotes] ([footnote_id])
GO
ALTER TABLE [dbo].[wix_filter_engine_footnote] CHECK CONSTRAINT [wix_filter_engine_footnote_fk1]
GO
ALTER TABLE [dbo].[wix_filter_engines]  WITH CHECK ADD  CONSTRAINT [wix_filter_engines_fk0] FOREIGN KEY([filter_id])
REFERENCES [dbo].[wix_filters] ([filter_id])
GO
ALTER TABLE [dbo].[wix_filter_engines] CHECK CONSTRAINT [wix_filter_engines_fk0]
GO
ALTER TABLE [dbo].[wix_filter_engines]  WITH CHECK ADD  CONSTRAINT [wix_filter_engines_fk1] FOREIGN KEY([engine_id])
REFERENCES [dbo].[wix_engines] ([engine_id])
GO
ALTER TABLE [dbo].[wix_filter_engines] CHECK CONSTRAINT [wix_filter_engines_fk1]
GO
ALTER TABLE [dbo].[wix_filter_engines]  WITH CHECK ADD  CONSTRAINT [wix_filter_engines_fk2] FOREIGN KEY([model_id])
REFERENCES [dbo].[wix_models] ([model_id])
GO
ALTER TABLE [dbo].[wix_filter_engines] CHECK CONSTRAINT [wix_filter_engines_fk2]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes]  WITH CHECK ADD  CONSTRAINT [wix_filter_type_shapes_fk0] FOREIGN KEY([type_id])
REFERENCES [dbo].[wix_filter_types] ([type_id])
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] CHECK CONSTRAINT [wix_filter_type_shapes_fk0]
GO
ALTER TABLE [dbo].[wix_filter_type_shapes]  WITH CHECK ADD  CONSTRAINT [wix_filter_type_shapes_fk1] FOREIGN KEY([shape_id])
REFERENCES [dbo].[wix_filter_shapes] ([shape_id])
GO
ALTER TABLE [dbo].[wix_filter_type_shapes] CHECK CONSTRAINT [wix_filter_type_shapes_fk1]
GO
ALTER TABLE [dbo].[wix_filters]  WITH CHECK ADD  CONSTRAINT [wix_filters_fk0] FOREIGN KEY([filter_type_id])
REFERENCES [dbo].[wix_filter_types] ([type_id])
GO
ALTER TABLE [dbo].[wix_filters] CHECK CONSTRAINT [wix_filters_fk0]
GO
ALTER TABLE [dbo].[wix_filters]  WITH CHECK ADD  CONSTRAINT [wix_filters_fk1] FOREIGN KEY([filter_media_id])
REFERENCES [dbo].[wix_filter_medias] ([media_id])
GO
ALTER TABLE [dbo].[wix_filters] CHECK CONSTRAINT [wix_filters_fk1]
GO
ALTER TABLE [dbo].[wix_filters]  WITH CHECK ADD  CONSTRAINT [wix_filters_fk2] FOREIGN KEY([filter_style_id])
REFERENCES [dbo].[wix_filter_styles] ([style_id])
GO
ALTER TABLE [dbo].[wix_filters] CHECK CONSTRAINT [wix_filters_fk2]
GO
ALTER TABLE [dbo].[wix_filters]  WITH CHECK ADD  CONSTRAINT [wix_filters_fk3] FOREIGN KEY([filter_shape_id])
REFERENCES [dbo].[wix_filter_shapes] ([shape_id])
GO
ALTER TABLE [dbo].[wix_filters] CHECK CONSTRAINT [wix_filters_fk3]
GO
ALTER TABLE [dbo].[wix_filters]  WITH CHECK ADD  CONSTRAINT [wix_filters_fk4] FOREIGN KEY([filter_service_id])
REFERENCES [dbo].[wix_filter_services] ([service_id])
GO
ALTER TABLE [dbo].[wix_filters] CHECK CONSTRAINT [wix_filters_fk4]
GO
ALTER TABLE [dbo].[wix_filtron_cross]  WITH CHECK ADD  CONSTRAINT [wix_filtron_cross_fk0] FOREIGN KEY([wix_filter_id])
REFERENCES [dbo].[wix_filters] ([filter_id])
GO
ALTER TABLE [dbo].[wix_filtron_cross] CHECK CONSTRAINT [wix_filtron_cross_fk0]
GO
ALTER TABLE [dbo].[wix_filtron_cross]  WITH CHECK ADD  CONSTRAINT [wix_filtron_cross_fk1] FOREIGN KEY([filtron_filter_id])
REFERENCES [dbo].[filtron_filters] ([filter_id])
GO
ALTER TABLE [dbo].[wix_filtron_cross] CHECK CONSTRAINT [wix_filtron_cross_fk1]
GO
ALTER TABLE [dbo].[wix_interchanges]  WITH CHECK ADD  CONSTRAINT [wix_interchanges_fk0] FOREIGN KEY([filter_id])
REFERENCES [dbo].[wix_filters] ([filter_id])
GO
ALTER TABLE [dbo].[wix_interchanges] CHECK CONSTRAINT [wix_interchanges_fk0]
GO
ALTER TABLE [dbo].[wix_interchanges]  WITH CHECK ADD  CONSTRAINT [wix_interchanges_fk1] FOREIGN KEY([manufacturer_id])
REFERENCES [dbo].[wix_interchange_manufacturers] ([manufacturer_id])
GO
ALTER TABLE [dbo].[wix_interchanges] CHECK CONSTRAINT [wix_interchanges_fk1]
GO
ALTER TABLE [dbo].[wix_logistics_info]  WITH CHECK ADD  CONSTRAINT [wix_logistics_info_fk0] FOREIGN KEY([filter_id])
REFERENCES [dbo].[wix_filters] ([filter_id])
GO
ALTER TABLE [dbo].[wix_logistics_info] CHECK CONSTRAINT [wix_logistics_info_fk0]
GO
ALTER TABLE [dbo].[wix_makes]  WITH CHECK ADD  CONSTRAINT [wix_makes_fk0] FOREIGN KEY([vehicle_id])
REFERENCES [dbo].[wix_vehicles] ([vehicle_id])
GO
ALTER TABLE [dbo].[wix_makes] CHECK CONSTRAINT [wix_makes_fk0]
GO
ALTER TABLE [dbo].[wix_models]  WITH CHECK ADD  CONSTRAINT [wix_models_fk0] FOREIGN KEY([make_id])
REFERENCES [dbo].[wix_makes] ([make_id])
GO
ALTER TABLE [dbo].[wix_models] CHECK CONSTRAINT [wix_models_fk0]
GO
USE [master]
GO
ALTER DATABASE [wixeurope_new] SET  READ_WRITE 
GO
